Created
December 22, 2013 13:35
-
-
Save khannedy/8082744 to your computer and use it in GitHub Desktop.
Matching Berdasarkan Tipe Data
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
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) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@khannedy Nampak lagi intensif belajar dengan Scala nih :P