Pattern Matching On Types

One step beyond(!) that is matching on types.

def whatIsThis(value: Any): String = {
  value match {
    case int: Int => "It's an Int."
    case text: String => "It's a String: " + text
    case _ => "I don't know what it is."
  }
}

println(whatIsThis("Moshi"))
println(whatIsThis(1))
println(whatIsThis(1.2))