Skip to content

Instantly share code, notes, and snippets.

@czottmann
Created January 7, 2009 12:46
Show Gist options
  • Save czottmann/44268 to your computer and use it in GitHub Desktop.
Save czottmann/44268 to your computer and use it in GitHub Desktop.
class MyClass
attr_reader :myvar
def initialize
@myvar = "omg"
do_stuff
end
def do_stuff
raise RuntimeError
# exploding code here, raising an exception
end
end
begin
mc = MyClass.new
rescue
puts mc.myvar
# mc.myvar doesn't exist, since mc is actually nil
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment