Skip to content

Instantly share code, notes, and snippets.

@debop
Created January 8, 2013 14:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save debop/4484089 to your computer and use it in GitHub Desktop.
Save debop/4484089 to your computer and use it in GitHub Desktop.
Extractor
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)
}
}
@debop
Copy link
Author

debop commented Jan 8, 2013

Extractor 형식으로 처리할 수 있음. 이 기능은 다른 언어에는 없는 상당히 괜찮은 기능이다.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment