What’s the difference between === and == in ruby?

Posted by Rohit Kumar | Updated on

In this answer, I have shared what’s the difference between === and == in ruby? The == operator, also known as equality or double equal, will return true if both objects are equal and false if they are not.

I’m going to heavily quote the Object documentation here, because I think it has some great explanations. I encourage you to read it, and also the documentation for these methods as they’re overridden in other classes, like String.

Side note: if you want to try these out for yourself on different objects, use something like this:


If you like this question & answer and want to contribute, then write your question & answer and email to freewebmentor[@]gmail.com. Your question and answer will appear on FreeWebMentor.com and help other developers.

Related Questions & Answers