Going onto a new line

ok i am quite new to ruby and i am only 14 so… any way i am
struggling to get my test to go onto a new line here is the code i put
in (if you could copy and paste the code then make the changes in the
reply that would be great):
print(“uh…”)
sleep 1.5
print(“were am I?”)

it comes out as

**uh…**were am I?
and i want it to be

uh…
were am I?

thanks
Dan

print(“uh…”)

print “uh…\n”

or

puts “uh…

note, parens may not be needed here…

best regards -botp

thanks botp :slight_smile: works fine,

i had seen \n but

  1. i did not know where to put it in the string
  2. and i thought it was /n

Excerpts from Dan L.'s message of Sun Jan 30 03:06:24 +0100 2011:

ok i am quite new to ruby and i am only 14 so… any way i am
struggling to get my test to go onto a new line here is the code i put
in (if you could copy and paste the code then make the changes in the
reply that would be great):
print(“uh…”)
sleep 1.5
print(“were am I?”)

There are many ways. The most simple is this:

print "ath
"
print "ath
"

This will use the new line character from the source file.
However usually you use string quoting:

1.upto(10).each { |dummy| print “test\n” }

the \ gives the next character a special meaning. Here its ‘n’.

Marc W.

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