the12 the12 - 6 months ago 37
Ruby Question

Spaces in string vs. Escape sequences

In Ruby (testing in the Interactive Ruby Shell), you can either use spaces in strings or use escape sequences. Is there a best practice in determining which to use, or does it never matter?

For example:

"Hello World"

--> "Hello World"



--> "Hello World"


Use spaces. Makes it much more easier to read

If you cant, then use the escape sequences.

Also note that escape only works in double quotes

    --> 'Hello\\sWorld'