Is there any special Reason why the === and the == methods are implemented differently in the class Class?
>> "".class == String
=> true
>> "".class === String
=> false
>Solution :
We can further simplify your question I think.
I believe you are asking is why
String == String # true
But
String === String # false
I think it’s semi consistent by Ruby. the === equality asks if right side is a member of the left side.
So
Class === String
Is true since String is a member of Class. And indeed String is not a member of String.
What I do find weird though is that
5 === 5 # returns true
Imo it should return false to be consistent with String === String returning false, but for primitives Ruby has this quirk, probably so it works well with case statements.