Skip to content

Instantly share code, notes, and snippets.

@yangsu
Created January 28, 2013 03:47
Show Gist options
  • Save yangsu/4652864 to your computer and use it in GitHub Desktop.
Save yangsu/4652864 to your computer and use it in GitHub Desktop.
Ruby Instance Variables
class Person
attr :age
attr_reader :age
# gets translated into:
def age
@age
end
attr_writer :age
# gets translated into:
def age=(value)
@age = value
end
# attr_accessor :age gets will generate both of the methods above
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment