Re:Understanding Ruby Blocks, Procs and Lambdas
by raganwald on Wednesday December 31, 2008 @04:25PM
(#415906)
Sorry 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.
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.