Skip to content

Instantly share code, notes, and snippets.

@quicy
Created January 18, 2012 15:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save quicy/1633457 to your computer and use it in GitHub Desktop.
Save quicy/1633457 to your computer and use it in GitHub Desktop.
Collection filter by Xtend closure
import java.util.List
import static extension java.util.Collections.*
class CollectionFilter {
def static void main(String[] _) {
val values = newArrayList(1, 5, 0, -2, -10, 4)
val filtered = positiveOnly(values)
println(filtered)
}
def static positiveOnly(List<Integer> values) {
values.filter(v| v > 0)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment