Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Groovy - Guava classical set operations
@Grapes(
@Grab(group='com.google.guava', module='guava', version='18.0')
)
import static com.google.common.collect.Sets.*
def first = ['a', 'b', 'c'] as Set
def second = ['b', 'c', 'd', 'e'] as Set
println "In first not in second: ${difference(first, second)}"
println "In second not in first: ${difference(second, first)}"
println "Common: ${intersection(first, second)}"
println "All: ${union(first, second)}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.