Ruby - Classes and Objects
What will be the output of the following Ruby code?
a = "hello" b = "hello" puts a == b puts a.equal?(b)
a = "hello" b = "hello" puts a == b puts a.equal?(b)
a == ba and b are strings with the same content "hello", so a == b returns true.a.equal?(b)a and b are different string objects, so equal? returns false.== compares content, equal? compares object identity = C [OK]== checks value, equal? checks same object [OK]equal? returns true for identical strings== checks object identity15+ quiz questions · All difficulty levels · Free
Free Signup - Practice All Questions