21
Consider this class:
class DateTime(year: Int, month: Int, day: Int)(hour: Int, minute: Int, second: Int)
how would the unapply method look like, if I would like to match against something like:
dt match {
case DateTime(2012, 12, 12)(12, _, _) => // December 12th 2012, 12 o'clock
/* ... */
}
I tried this:
def unapply(dt: DateTime) =
Some((dt.year, dt.month, dt.day),(dt.hour, dt.minute, dt.second))
But that didn't really work.