Possible Duplicate:
Using 'return' in a Ruby block
I'm new to Ruby, and was surprised that this snippet raise
a LocalJumpError
when the block return
:
$bail_if = proc { |condition|
if condition
puts 'the condition is true'
return
else
puts 'the condition is false'
end
}
def method some_condition
$bail_if[some_condition]
end
method true
If I defined bail_if
as a local variable in def method
, then there is no problem. Why is this?