Closed
Description
I suggest adding a note about control structures-match-using default value
- Using variable bindings, you have to keep in mind, that any form of catch-all effectively breaks the matching chain. Some systems provide lookup for the most specific matches, but Scala's match does not. This error is easier to catch in the case of underscore placeholder but can be easily missed for var bindings. Especially if you suppress or ignore (not dive in) compiler warnings. This notch is a regular source of bad mistakes:
val i = 5
val day = i match
case 0 => "Sunday"
case 1 => "Monday"
case 2 => "Tuesday"
case 3 => "Wednesday"
case what => "Guesswho"
case 4 => "Thursday"
case 5 => "Friday"
case 6 => "Saturday"
println(day)
Guesswho
Metadata
Metadata
Assignees
Labels
No labels