Last active
June 6, 2016 12:47
-
-
Save phurni/392d5a962e40cd093c5ca6d45683077b 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
# 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