Apart from:
case class A
... case which is quite useful?
Why do we need to use case
in match
? Wouldn
Adding to @Mik378's answer:
When you write this: (a, b) => something
, you are defining an anonymous Function2
- a function that takes two parameters.
When you write this: case (a, b) => something
, you are defining an anonymous PartialFunction
that takes one parameter and matches it against a pair.
So you need the case
keyword to differentiate between these two.