Possible Duplicate:
=== vs. == in Ruby
Can I assume they are the same?
if foo == "bar"
vs
if foo === "bar"
Thanks.
Possible Duplicate:
=== vs. == in Ruby
Can I assume they are the same?
if foo == "bar"
vs
if foo === "bar"
Thanks.
They are not the same. The short answer is that ==
checks if the values are the same, but type-casts if necessary. ===
is only true if the values AND types are the same.
0 == "0" #=> true
0 === "0" #=> false
0 === 0 #=> true
There are (literally) millions of discussions about this on the internet, as this is not, by a long-shot, a Ruby-specific thing. Try a Google search if you'd like more information.
Edit
I made a mistake, this is incorrect.