3 ms·
Ruby's if/elsif/else statement returns a value making it a nice alternative to trenary operators. I have for the world not understood why one would do it otherw
by bjoli 8y ago
Ruby's if/elsif/else statement returns a value making it a nice alternative to trenary operators. I have for the world not understood why one would do it otherwise.
Unless you want to use mutation you have to use it in python, and then you end up with ugly chains if you want brevity.
- underwater 8y agoIf it returns a value then wouldn't it be an if expression, not an if statement? It certainly sounds like a useful feature, as someone who writes a lot of JavaScript I can see the value (and I believe a form of this is coming to JS in the form of `do` expressions).
- rad_gruchalski 8y agoIn Ruby, everything is an expression. I also miss Ruby’s unless in many languages.