Created
January 8, 2013 14:16
-
-
Save debop/4484089 to your computer and use it in GitHub Desktop.
Extractor
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
case class Currency(value: Double, unit: String = "USD") | |
@Test | |
def extractorMatch() { | |
val amt = new Currency(29.95, "EUR") | |
amt match { | |
case Currency(amount, "USD") => log.debug(s" $$$amount") | |
case Currency(amount, "EUR") => log.debug(s"€$amount") | |
case _ => log.debug(amt) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Extractor 형식으로 처리할 수 있음. 이 기능은 다른 언어에는 없는 상당히 괜찮은 기능이다.