\ is an escape character for strings. For example, using
a = ‘Today is the day, I’m going to New Jersey’
is interpreted as
a = ‘Today is the day, I’ m going to New Jersey ’
This tosses an error because the interpreter assumes the apostrophe in
I’m
is the end of the string. The \ escapes that apostrophe so that it’s
merely
text in the string, not a Ruby operator. The above line would also error
out
because ‘m’, ‘going’, ‘to’, ‘new’, and ‘jersey’ are unknown methods, and
then also because the last ’ was read as the beginning of another
string,
causing the string to run to the end of the file and the interpreter
yelling
at you because the string wasn’t terminated. (In other contexts it would
run
until the next occurrence of the ’ character, tossing other errors.)