Created
January 18, 2012 15:15
-
-
Save quicy/1633457 to your computer and use it in GitHub Desktop.
Collection filter by Xtend closure
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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