Ruby/Class/eql

Материал из Wiki.crossplatform.ru

Перейти к: навигация, поиск

eql and == are different

1 == 1.0    # true: Fixnum and Float objects can be ==
1.eql?(1.0) # false: but they are never eql!



Use === to compare values

(1..10) === 5    # true: 5 is in the range 1..10
/\d+/ === "123"  # true: the string matches the regular expression
String === "s"   # true: "s" is an instance of the class String
:s === "s"       # true in Ruby 1.9