Skip to content

Instantly share code, notes, and snippets.

@phurni
Last active June 6, 2016 12:47
Show Gist options
  • Save phurni/392d5a962e40cd093c5ca6d45683077b to your computer and use it in GitHub Desktop.
Save phurni/392d5a962e40cd093c5ca6d45683077b to your computer and use it in GitHub Desktop.
# Original code from https://github.com/shakycode/ruby_sunday_refactor
# Second refactor, the addresses are objects! Create an address class that uses ValueType semantics
Address = Struct.new(:house_number, :street_address) do
def initialize(address)
super(*address.split(' ', 1).map(&:strip))
end
end
# now to compare two addresses, create instance of the Address class and compare those objects with the == operator
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment