3 ms·
I respectfully disagree that the return keyword is more trouble than it is worth. "return false if simple_question?" ... rest of the body is a very useful thi
by aaronblohowiak 18y ago
I respectfully disagree that the return keyword is more trouble than it is worth.
"return false if simple_question?"
... rest of the body
is a very useful thing to do. granted, you might say it is "programming by GOTO", but it lowers the indentation level, and so keeps me happy.
To the GP: we can also .to_proc on blocks.
- raganwald 18y agoSorry I didn't see this when you posted it. The problem is not `return :foo if bar()`, it's something like `pizzles.each { |p| return :foo if p.bar() }`. In Ruby, that returns from the surrounding method, not from the block where it's defined. You can decide for yourself if this behaviour of return more trouble than it's worth. I didn't say it was, I said that this definition is what forces a block to be something different from a proc, which makes the language more complicated.