Skip to content

Instantly share code, notes, and snippets.

@queso
Created April 11, 2010 02:33
Show Gist options
  • Save queso/362452 to your computer and use it in GitHub Desktop.
Save queso/362452 to your computer and use it in GitHub Desktop.
def long_method
@running = true
begin
really_long_code
ensure
@running = false
end
end
long_method # => NameError: undefined local variable or method `really_long_code' for #<Object:0x102310508>
puts @running # => false
def long_method
@running = true
begin
really_long_code
rescue
ensure
@running = false
end
end
long_method # => nil
puts @running # => false
def long_method
@running = true
return if @running
really_long_code
ensure
@running = false
end
long_method # => nil
puts @running # => false
def long_method
@running = true
return
begin
really_long_code
ensure
@running = false
end
end
long_method # => nil
puts @running # => true
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment