Forum: Ruby how to print two outputs on the same line in window terminal

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
73700e119917433681f2e8f3e4369f74?d=identicon&s=25 Li CN (alex-osu3)
on 2014-04-26 15:19
Hi all,

I want to print two outputs on the same line in window terminal but
don't know which method is used. Here my script:

print "question 1---"
gets #user will hit enter when he  is ready to answer
puts "correct answers is......."

instead of getting output in two lines as

question 1---
correct answer is.....

I like to the output on one line  as
question 1---correct answer is.....


14b5582046b4e7b24ab69b7886a35868?d=identicon&s=25 Joel Pearson (virtuoso)
on 2014-04-27 22:42
You cannot do this with the normal console. If you need to manipulate
the appearance in that way you'll need a custom UI.
73700e119917433681f2e8f3e4369f74?d=identicon&s=25 Li CN (alex-osu3)
on 2014-04-28 02:00
Thank you Joel.
73700e119917433681f2e8f3e4369f74?d=identicon&s=25 Li CN (alex-osu3)
on 2014-04-29 04:13
Hi Joel,

I can print two outputs on the same line on iPad with Rubyi but cannot
do it on window 8.
Bacf885eeb3ccdfa0027e8342ef01194?d=identicon&s=25 Ed Goulart (edgoulart)
on 2014-05-08 15:30
Hi, Alex!
Instead of:              puts "correct answers is......."
try:                     print "correct answers is......."
and, in some situations: p "correct answers is......."
would do the job.
This topic is locked and can not be replied to.