You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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
The text was updated successfully, but these errors were encountered:
I suggest adding a note about control structures-match-using default value
The text was updated successfully, but these errors were encountered: