Quick question: continuing Ruby methods on different line

If you have a long method call like:

some.long.method.call

how can i make it

some.long (next line)
.method.call

On Sat, 30 Sep 2006, Eric G. wrote:

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

[email protected] wrote:

.method.call
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. :slight_smile:

$ 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

On 9/30/06, Robert K. [email protected] wrote:

[email protected] wrote:

On Sat, 30 Sep 2006, Eric G. wrote:

Ara’s
p Time
.now
is fine, but even

p Time.
now

works, if you forget the dot, however :frowning:

Kind regards

    robert

I agree with this sentence 8-]


Deux choses sont infinies : l’univers et la bêtise humaine ; en ce qui
concerne l’univers, je n’en ai pas acquis la certitude absolue.

  • Albert Einstein

On 9/30/06, Robert D. [email protected] wrote:

p Time.
now

As you said, I somehow missed the first part of your post:(
Sorry 4 the noise
Robert


Deux choses sont infinies : l’univers et la bêtise humaine ; en ce qui
concerne l’univers, je n’en ai pas acquis la certitude absolue.

  • Albert Einstein

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs