Skip to content

Instantly share code, notes, and snippets.

@amacleod
Created January 20, 2011 16:35
Show Gist options
  • Save amacleod/788141 to your computer and use it in GitHub Desktop.
Save amacleod/788141 to your computer and use it in GitHub Desktop.
case class Month(m: Int)
implicit def IntToMonth(n: Int) = Month(n)
case class YearMonth(y: Int, m: Month) {
def unapply(in: (Int, Int)): Option[(Int, Month)] = Some(in._1, Month(in._2))
}
YearMonth(2011, Month(1)) match {
case YearMonth(2011, 1) => println("now")
case _ => println("not now")
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment