Ruby : Writing Very long string in multiple lines

Using backward slash (\) at the end of line tells the ruby parser that the line is still incomplete. Also the parser concatenates the two string into one.

> long_sentence = "This is a very long sentence and this line even cannot"\
> " be written in one line"
 => "This is a very long sentence and this line even cannot be written in one line"

 

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s