I made tests with the result, that neither “eql?” nor “hash” is called.
What
went wrong here?
code >>>>>
class String
alias :org_hash :hash
alias :org_eql? :eql?
def hash
puts ‘String#hash called’
self.org_hash
end
def eql?(other)
puts ‘String#eql? called’
self.org_eql?(other)
end
end
puts ‘Start of test’
a = [‘a’, ‘b’, ‘a’, ‘c’, ‘b’]
b = a.uniq
p b
puts ‘End of test’
puts ‘Regexp:’
p [ /a/, /b/, /a/, /c/, /b/ ].uniq
puts ‘String:’
p %w(a b a c b).uniq
puts “\nRegards, Kalman”
END
Output:
Regexp:
hash called
hash called
hash called
eql? called
hash called
hash called
eql? called
hash called
hash called
hash called
hash called
hash called
[/a/, /b/, /c/]
String:
[“a”, “b”, “c”]