Skip to content

Instantly share code, notes, and snippets.

@sideshowcoder
Created October 13, 2010 14:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sideshowcoder/624138 to your computer and use it in GitHub Desktop.
Save sideshowcoder/624138 to your computer and use it in GitHub Desktop.
class A
# Allow read access to var
attr_reader :var
# Set the INSTANCE variable var
def set
@var = "I am an instance variable"
end
# Print the LOCAL variable
def show
puts var
end
end
# Create a new INSTANCE of Access
a = A.new
# Print the LOCAL variable
a.show
# => nil
# Set the instance variable
a.set
# Print the LOCAL variable again
a.show
# => I am an instance variable
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment