Continued Strings

  • Thread starter James Edward Gray II
  • Start date
J

James Edward Gray II

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
 
E

Eric Hodel

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.

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

vikkous

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.)
 
J

Jim Freeze

* vikkous said:
"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.
 

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,172
Messages
2,570,933
Members
47,472
Latest member
blackwatermelon

Latest Threads

Top