Created
January 7, 2012 22:50
-
-
Save diegopacheco/1576357 to your computer and use it in GitHub Desktop.
Scala Pattern Matcher with var
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 MatcherThisVar extends App { | |
| class Sample{ | |
| val max = 100 | |
| val MIN = 0 | |
| def process(input:Int){ | |
| input match{ | |
| case this.max => println("This max 100") | |
| case MIN => println("MIN 0") | |
| case _ => println("???") | |
| } | |
| } | |
| } | |
| new Sample().process(100) | |
| new Sample().process(0) | |
| new Sample().process(2) | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment