I type the following:
>> x.inspect
"\"53219847091d6601dd000004\""
>> "53219847091d6601dd000004".inspect
"\"53219847091d6601dd000004\""
>> "53219847091d6601dd000004"==x
false
They are the same so why they are not equal to each other?
I type the following:
>> x.inspect
"\"53219847091d6601dd000004\""
>> "53219847091d6601dd000004".inspect
"\"53219847091d6601dd000004\""
>> "53219847091d6601dd000004"==x
false
They are the same so why they are not equal to each other?
inspect
returns a string representation of your object, its implementation is up to the class:
class Foo
def inspect
"I'm Foo"
end
end
class Bar
def inspect
"I'm Foo"
end
end
foo = Foo.new
bar = Bar.new
foo.inspect
#=> "I'm Foo"
bar.inspect
#=> "I'm Foo"
foo
and bar
have the same inspect
value, but they are not equal:
foo == bar
#=> false
In fact, they are totally different objects:
foo.class #=> Foo
bar.class #=> Bar