Skip to content

Instantly share code, notes, and snippets.

@samiron
Created March 7, 2010 05:11
Show Gist options
  • Save samiron/324165 to your computer and use it in GitHub Desktop.
Save samiron/324165 to your computer and use it in GitHub Desktop.
A simplified demo on using attr_writer(setter method). Here the attr_reader(getter method) is not used so you need to define a method to get the instance variable.
class Human
attr_writer :name
def name
return @name
end
end
me = Human.new
me.name = 'samiron'
puts me.name
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment