Last active
December 20, 2015 21:09
-
-
Save lu911/6195580 to your computer and use it in GitHub Desktop.
Set method test
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
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