Created
September 26, 2013 18:49
-
-
Save OfTheDelmer/6718810 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 Person | |
def initialize(name="no name") | |
@name = name | |
end | |
# Set method it | |
def name=(other_name) | |
@name = other_name | |
end | |
# Get method | |
def name | |
@name | |
end | |
def say_hello | |
puts "Hello, I am #{@name}" | |
end | |
end | |
person = Person.new() | |
# Setter method for name | |
person.name = "Smith" | |
person.say_hello | |
# Getter method for name | |
puts person.name |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment