Created
January 7, 2012 21:58
-
-
Save diegopacheco/1576187 to your computer and use it in GitHub Desktop.
Scala Pattern Matcher Tuples
This file contains hidden or 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 MatcherOnTuples extends App { | |
| def pointRef(i:Any) = i match { | |
| case (x,y, 55) => printf("x y and 55") | |
| case (x,y) => printf("Point X %s Y %s \n",x,y) | |
| case (3) => printf("This is 3") | |
| case (x) => printf("Point X %s \n",x) | |
| } | |
| pointRef( (1,2) ) | |
| pointRef( (3) ) | |
| pointRef( false ) | |
| pointRef( (3,Int) ) | |
| pointRef( (1,"1",55) ) | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment