Continued Strings

Here's an interesting code fragment from a Ruby Quiz solution this week:

     puts "\nShortest path from #{m.pos2coord(p1).inspect} to " \
     "#{m.pos2coord(p2).inspect}:", m.to_s(path)

Does Ruby concatenate those two String fragments because of the \ line continuation? I didn't know that.

James Edward Gray II

puts "Yes..." " " "it does"

···

On 11 May 2005, at 17:19, James Edward Gray II wrote:

Here's an interesting code fragment from a Ruby Quiz solution this week:

    puts "\nShortest path from #{m.pos2coord(p1).inspect} to " \
    "#{m.pos2coord(p2).inspect}:", m.to_s(path)

Does Ruby concatenate those two String fragments because of the \ line continuation? I didn't know that.

--
Eric Hodel - drbrain@segment7.net - http://segment7.net
FEC2 57F1 D465 EB15 5D6E 7C11 332A 551C 796C 9F04

Does Ruby concatenate those two String fragments because of the \
line continuation?

Nope, try it in irb. No backslash necessary:

"foo" "bar" # => "foobar"

(I didn't know that worked either, or i had forgotten. Cute.)

* vikkous <google@inforadical.net> [2005-05-12 09:40:27 +0900]:

> Does Ruby concatenate those two String fragments because of the \
> line continuation?

"foo" "bar" # => "foobar"

(I didn't know that worked either, or i had forgotten. Cute.)

This is (last I heard) going away with rite. You may want
to avoid this feature.

···

--
Jim Freeze
Ruby: I can explain it to ya but I can't understand it fer ya.