I know that reverse creates a new line with line characters in reverse order and that reverse! mutates (cancels) the current line in place. My question is why, when, for example, testing for a palindrome, does this happen ?:
a = "foobar"
a == a.reverse # => false
a == a.reverse! # => true
This is because it is the same object in memory, so == just checks to see if it has the same memory location?
Thank!
source
share