Created
October 13, 2010 14:34
-
-
Save sideshowcoder/624138 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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