I wonder why there doesn’t exist a literal for partial function types. I have to write
val pf: PartialFunction[Int, String] = {
case 5 => "five"
}
where an literal like :=> would be shorter:
val pf: Int :=> String = {
case 5 => "five"
}
Partial functions are often used and in Scala already some “special” feature, so why no special syntax for it?
Probably in part because you don’t need a literal: you can always write your own
:=>as a type infix operator if you want more concise syntax:I’m not one of the designers of the Scala language, though, so this is more or less a guess about the “why?”. You might get better answers over at the
scala-debatelist, which is a more appropriate venue for language design questions.