views:

164

answers:

1

If I have a statement in Ruby that I want to continue on the next line, normally I would add a backslash at the end of the line like this:

print x \
+ y

But if I have comments on the line, it doesn't work:

print x #show x 
+ y # show y

Is there a way around this?

(Edit: Squeegy's solution is correct and, actually, I knew you could do that but I was wondering particularly whether there is a way to have a comment on the same line as the backslash).

+5  A: 

You need to plus sign on the first line. I dont think comments work with the blackslash

puts 'abc' + #Start abc
  'def'      #Add def
Squeegy
I was actually wondering whether there is a way to have a comment on the same line as the backslash but after seeing beautifulpixel I'll gladly take your word that there isn't :) Thanks.
Bryan Locke