quick question: continuing Ruby methods on different line

E

Eric Gross

If you have a long method call like:


some.long.method.call

how can i make it

some.long (next line)
method.call
 
A

ara.t.howard

If you have a long method call like:


some.long.method.call

how can i make it

some.long (next line)
.method.call

harp:~ > cat a.rb
p Time\
now

harp:~ > ruby a.rb
Fri Sep 29 20:59:45 MDT 2006


-a
 
R

Robert Klemme

You just need to place the dot in the first line:

some.long.
method.call

Or you have to escape the line ending
some.long\
..method.call
harp:~ > cat a.rb
p Time\
now

harp:~ > ruby a.rb
Fri Sep 29 20:59:45 MDT 2006

How did you get that to work? I think you're missing a point here. :)

$ ruby <<XXX
puts Time\
now
XXX
-:1: uninitialized constant Timenow (NameError)

But these work

$ ruby <<XXX
puts Time.
now
XXX
Sat Sep 30 10:42:14 GMT+1:00 2006

$ ruby <<XXX
puts Time\
.now
XXX
Sat Sep 30 10:43:18 GMT+1:00 2006

Kind regards

robert
 

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,213
Messages
2,571,109
Members
47,701
Latest member
LeoraRober

Latest Threads

Top