Created
November 23, 2016 05:55
-
-
Save alexandru-calinoiu/16d5c5e1a15cb435b10658ca3c0d922a 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 UserAddressBook | |
attr_accessor :user_id, :address_book_entry | |
def initialize(user_id, address_book_entry) | |
@user_id = user_id | |
@address_book_entry = address_book_entry | |
end | |
end | |
address_book1 = UserAddressBook.new(42, 'test') | |
address_book2 = UserAddressBook.new(42, 'test') | |
p address_book1 == address_book2 # false | |
UserAddressBookStruct = Struct.new(:user_id, :address_book_entry) | |
struct1 = UserAddressBookStruct.new(user_id: 42, address_book_entry: 'test') | |
struct2 = UserAddressBookStruct.new(user_id: 42, address_book_entry: 'test') | |
p struct1 == struct2 # true |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment