Skip to content

Instantly share code, notes, and snippets.

@hussachai
Created November 7, 2015 05:18
Show Gist options
  • Save hussachai/80b51a117e4ba5205a29 to your computer and use it in GitHub Desktop.
Save hussachai/80b51a117e4ba5205a29 to your computer and use it in GitHub Desktop.
//Scala - strict collection
pets.filter { pet => pet.getBirthdate.isBefore(LocalDate.of(2013, Month.JANUARY, 1))}
.filter { pet => pet.getWeight > 50 } //List[Pet]
//Scala - non-strict collection
pets.views.filter { pet => pet.getBirthdate.isBefore(LocalDate.of(2013, Month.JANUARY, 1))}
.filter { pet => pet.getWeight > 50 } //SeqView[Pet]
//Scala - stream
pets.toStream.filter { pet => pet.getBirthdate.isBefore(LocalDate.of(2013, Month.JANUARY, 1))}
.filter { pet => pet.getWeight > 50 } //Stream[Pet]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment