object fivetimes {
def apply(x : Int) = x * 5
def unapply(z : Int) = if(z%5==0) Some(z/5) else None
}
object threetimes {
def apply(x : Int) = x * 3
def unapply(z : Int) = if(z%3==0) Some(z/3) else None
}
val x = 12
x match {
case fivetimes(y) => println(x+" is five times "+y)
case threetimes(y) => println(x+" is three times "+y)
case _ => println(x+" is something else")
}