Created
March 7, 2010 05:11
-
-
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.
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 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