Last active
December 19, 2015 04:19
-
-
Save keithrbennett/5896438 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 Name | |
attr_accessor :first_name, :last_name | |
def initialize(first_name, last_name) | |
@first_name = first_name | |
@last_name = last_name | |
end | |
def name | |
"#{first_name} #{last_name}" | |
end | |
def ==(other) | |
name == other.name | |
end | |
end | |
class ClothingManufacturer | |
attr_accessor :name #, ... | |
def initialize(name) | |
@name = name | |
end | |
end | |
o1 = Name.new('Calvin', 'Klein') | |
o2 = ClothingManufacturer.new('Calvin Klein') | |
puts o1 == o2 | |
# prints: true |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment