Skip to content

Instantly share code, notes, and snippets.

@lu911
Last active December 20, 2015 21:09
Show Gist options
  • Save lu911/6195580 to your computer and use it in GitHub Desktop.
Save lu911/6195580 to your computer and use it in GitHub Desktop.
Set method test
object Main {
def main(args: Array[String]): Unit = {
new SetMethods()
}
}
class SetMethods {
private val digits = Set(1,3,5,7)
println("digits : " + digits)
val methods = List(contains, union, intersect, diff)
def contains(): Unit = {
println("-"*5 + " digits contains 1 " + "-"*5)
println(digits contains 1)
}
def union(): Unit = {
println("-"*5 + " digits union Set(2,3,5,7) " + "-"*5)
println(digits union Set(2,3,5,7))
}
def intersect(): Unit = {
println("-"*5 + " digits intersect Set(2,3,5,7) " + "-"*5)
println(digits intersect Set(2,3,5,7))
}
def diff(): Unit = {
println("-"*5 + " digits diff Set(2,3,5,7) " + "-"*5)
println(digits diff Set(2,3,5,7))
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment