Skip to content

Instantly share code, notes, and snippets.

@keithrbennett
Last active December 19, 2015 04:19
Show Gist options
  • Save keithrbennett/5896438 to your computer and use it in GitHub Desktop.
Save keithrbennett/5896438 to your computer and use it in GitHub Desktop.
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