== and equal" are different : equal « Class « Ruby






== and equal" are different


a = "Ruby"    # One String object
b = "Ruby"    # A different String object with the same content
a.equal?(b)   # false: a and b do not refer to the same object
a == b        # true: but these two distinct objects have equal values

 








Related examples in the same category

1.Use equal? to check the references
2.Same value but different reference