Matching on Type
You can use match
to handle values of different types differently.
def bigger(num: Any): Any = {
num match {
case i: Int if i < 0 => i-1
case i: Int => i+1
case d: Double if i < 0 => i-0.1
case d: Double => i+0.1
case text: String => text + "s"
}
}