Hi,
In message "Re: break in yield/block"
on 03/11/20, matt <mhm26 / drexel.edu> writes:
|I figured that was why break was terminating in #[] - but why not have
|yield act as a `method' in this sense? My guess is that in this
|respect, they should be the same.
They cannot be same. I would surprise if calling Proc#[] terminates
meow(). But I prepared the way to make meow behave as you expect:
def meow(doyield, &block)
puts "in meow #{doyield}"
if doyield
yield
else
block[]
end
puts "leaving meow"
rescue LocalJumpError
return
end
b = Proc.new {
puts "in proc"
break
puts "leaving proc"
}
meow(true, &b)
puts
meow(false, &b)
Tip: do not use "proc" nor "lambda" when you want objectified Block.
matz.