Created
September 26, 2013 19:23
-
-
Save OfTheDelmer/6719239 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 | |
attr_reader :name, :age | |
def initialize(name="no name", age) | |
@name = name | |
@age = age | |
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("Luke", 13) | |
puts person.age | |
# # Setter method for name | |
# person1.name = "Smith" | |
# person1.say_hello | |
# # Getter method for name | |
# puts person1.name | |
# person2 = Person.new("Luke") | |
# puts person1.object_id | |
# puts person2.object_id | |
# puts person1.object_id == person2.object_id | |
# puts person2.name | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment