ruby-dev summary 21637-21729

G

Gavin Sinclair

Is the syntax error because of the first line or because of the second?
I ask because I do this a lot in my code:
s = "this is a string " \
"that I have chosen to break " \
"into multiple lines
I would be happy to switch to using heredocs if there were an easy way
to indent heredocs.


require 'extensions/all' # http://extensions.rubyforge.org

s = %{
| this is a string
| that I have chosen to break
| into multiple lines
}.trim('|')

# or

s = %{
this is a string
that I have chosen to break
into multiple lines
}.trim.tabto(0)

That would produce a three-line string, unlike your example, but you
mention indenting heredocs, so there you go.

Cheers,
Gavin
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,139
Messages
2,570,805
Members
47,356
Latest member
Tommyhotly

Latest Threads

Top