3 ms·
This is the reason I don't use else much and use explicitly matching. `if/else` is pretty much only use for boolean with exact 2 states. Not like this issue b
by kureikain 7y ago
This is the reason I don't use else much and use explicitly matching.
`if/else` is pretty much only use for boolean with exact 2 states.
Not like this issue but the use of `if/else` can lead to thing like:
loop do
# do thing and increase i
break if i == 10
end
If i go from 9 to 11, we never exit the loop.
In language like Erlang, when you write `if/else` it force you to handle all the cases with pattern matching which I think may help reduce amount of unhandled state check error.
- jacquesm 7y agoDefensive code would have you write 'break if i >= 10'.