Skip to content

Instantly share code, notes, and snippets.

@CraigMorton
Last active October 3, 2017 13:33
Show Gist options
  • Save CraigMorton/254661d96657aa51c10b54e7e9234679 to your computer and use it in GitHub Desktop.
Save CraigMorton/254661d96657aa51c10b54e7e9234679 to your computer and use it in GitHub Desktop.
a_string = String.new('a_string')
another_string = String.new('another_string')
puts a_string
puts a_string.hash
puts another_string
puts another_string.hash
puts a_string.hash == another_string.hash
a_hash = {}
a_hash[a_string] = 5000
a_hash[another_string] = 10
puts a_hash
class BrokenString < String
def hash
return 1
end
end
a_broken_string = BrokenString.new('a_broken_string')
another_broken_string = BrokenString.new('another_broken_string')
puts a_broken_string
puts a_broken_string.hash
puts another_broken_string
puts another_broken_string.hash
puts a_broken_string.hash == another_broken_string.hash
a_broken_hash = {}
a_broken_hash[a_broken_string] = 5000
a_broken_hash[another_broken_string] = 10
puts a_broken_hash
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment