Created
January 29, 2014 21:57
-
-
Save emiaj/8697991 to your computer and use it in GitHub Desktop.
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
case class Car(Brand:String) | |
val tuple = ("this","is","a","tuple", 19, Car("Ford")) | |
// iterating over all items | |
tuple.productIterator.foreach(println) | |
/* | |
this | |
is | |
a | |
tuple | |
19 | |
Car(Ford) | |
*/ | |
tuple.productIterator.foreach({ | |
case x:String => println("string " + x) | |
case x:Int => println("int " + x); | |
case x:Car => println("car " + x.Brand) | |
}); | |
/* | |
string this | |
string is | |
string a | |
string tuple | |
int 19 | |
car Ford | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment