5 ms·
i use this in ruby and thought it was fine at first. but after looking back at older code or code others have written i have changed my mind and think it is usu
by asdf333 8y ago
i use this in ruby and thought it was fine at first. but after looking back at older code or code others have written i have changed my mind and think it is usually better to avoid it.
i think it makes it more complicated to think about because it requires some backtracking in thought
- bjoli 8y agoRuby'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.