eql? and == are slightly different : eq « String « Ruby






eql? and == are slightly different


# == returns true if two objects are Strings, false otherwise.
# eql? returns true if two strings are equal in length and content, false otherwise.

# Here eql? returns false:

hay = 'aaa'
aaa = 'aaa'
puts (hay.eql? aaa)

 








Related examples in the same category