Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Continuing a statement on the next line WITH A COMMENT

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).

like image 220
Bryan Locke Avatar asked Feb 24 '09 22:02

Bryan Locke


People also ask

How do you continue on the next line?

When it is necessary to continue to the next line, use a plus (+) or minus (-) sign as the last character of the line you want to continue. Note: If you are using REXX commands and want to continue to the next line, the plus or minus sign does not work. You must use the comma.

How do you continue a comment on the next line in Python?

You cannot split a statement into multiple lines in Python by pressing Enter . Instead, use the backslash ( \ ) to indicate that a statement is continued on the next line.

How do you continue commenting on the next line in Matlab?

If a statement does not fit on one line, enter three periods ( ... ) , also called dots, stops, or an ellipsis, at the end of the line to indicate it continues on the next line. Then press Enter or Return. Continue typing the statement on the next line.

What is continue line?

Any sentence, entry, clause, or phrase that requires more than one line can be continued in Area B of the next line that is neither a comment line nor a blank line. The line being continued is a continued line ; the succeeding lines are continuation lines .


1 Answers

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

puts 'abc' + #Start abc
  'def'      #Add def
like image 158
Alex Wayne Avatar answered Oct 18 '22 10:10

Alex Wayne