Andy McKay

Mar 17, 2007

Sometimes Ruby is annoying

Well its annoying a lot of the time to me since it's so magical. Yes I got bitten by the difference between single quoted strings (') and double quoted strings ("). In the previous there are very few escape sequences, in the latter there are more. What got me was a good old newline: \n

Python 2.4.4 (#1, Feb 18 2007, 22:11:27) 
>>> '\n' == "\n"

And now in Ruby:

~ $ irb
irb(main):001:0> '\n' == "\n"
=> false

This isn't hidden, it's documented (for example), but to me it's a strange language decision. For a Python programmer it's certainly a gotcha.