2 ms·
In ruby, the equivalent to a switch (confusingly called case) can take no initial-compare field and basically become a chained-if that lines up nicely (or more
by stormbrew 13y ago
In ruby, the equivalent to a switch (confusingly called case) can take no initial-compare field and basically become a chained-if that lines up nicely (or more nicely than elsifs). I prefer the visual look of it, personally, but it seems that a lot of people find it too confusing.
As an example:
case
when (a == 1)
dosomething
when (b == 2)
dosomethingelse
when (c)
orthis
else
awww
end