Skip to content

Instantly share code, notes, and snippets.

@bradediger
Created March 21, 2009 16:16
Show Gist options
  • Save bradediger/82888 to your computer and use it in GitHub Desktop.
Save bradediger/82888 to your computer and use it in GitHub Desktop.
def set_my_ivar
@my_ivar = 'set'
end
class A
attr_reader :my_ivar
def test_the_setting
set_my_ivar
end
end
a = A.new
a.test_the_setting
puts "a: #{a.my_ivar.inspect}"
puts "main: #{@my_ivar.inspect}"
# a: "set"
# main: nil
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment