Skip to content

Instantly share code, notes, and snippets.

@khannedy
Created December 22, 2013 13:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save khannedy/8082744 to your computer and use it in GitHub Desktop.
Save khannedy/8082744 to your computer and use it in GitHub Desktop.
Matching Berdasarkan Tipe Data
val data = List("Eko", "Kurniawan", 1, 2, 3, true, false, 'LAKI_LAKI, new Date())
for (value <- data) {
value match {
case i: Int => println(i + " is Integer")
case s: String => println(s + " is String")
case b: Boolean => println(b + " is Boolean")
case sym: Symbol => println(sym + " is Symbol")
case other => println(other + " is " + other.getClass.getName)
}
}
@muhammadghazali
Copy link

@khannedy Nampak lagi intensif belajar dengan Scala nih :P

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment