ruby 2.2.2p95 (2015-04-13 revision 50295) [x86_64-darwin14]
class A
end
a = A.new
A === a
# true
But it is not communative
a === A
# false
/f/ === "foo"
# true
But again not the reverse
"foo" === /f/
# false
"string" === "string"
# true
a = "str"
b = "str"
a === b
# true
And if they are the same type, it falls back to regular equality
class A
def ==(other)
# this will get caled by ===
true
end
end
a = A.new
b = A.new
a === b
# true
(1..10) === 5
# true
5 === (1..10)
# false
case "string"
when /s/
puts "matches /s/"
when "string"
puts "is equal to string"
when String
puts "is an instance of string"
when ('a'..'zzzzzz')
puts 'is between 1 and 5 alpha only characters'
end