Mark "case" keyword as optional in pattern "match" #19599
Replies: 3 comments
-
The RHS is a block; |
Beta Was this translation helpful? Give feedback.
-
Got it. I realized that OCaml and Rust uses symbols for disambiguation: let result = match x with
| 0 -> "Zero"
| n when n > 0 -> "Positive"
| n when n < 0 -> "Negative"
| _ -> "Unknown" let result = match x {
0 => "Zero"
, n if n > 0 => "Positive"
, n if n < 0 => "Negative"
, _ => "Unknown"
} I wish Scala was as minimal as Ocaml and/or Rust. |
Beta Was this translation helpful? Give feedback.
-
I also felt as @jaisw7 initially about the As another, and arguably more important, defense of |
Beta Was this translation helpful? Give feedback.
-
Instead of
I believe
is more concise.
I was wondering if there is a particular reason for using
case
keyword e.g., it makes the grammar unambiguous? If not, can we keep it as optional? I can submit a patch if everyone is aligned.Beta Was this translation helpful? Give feedback.
All reactions