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

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
98a99a727615dfffe04a65db0915dd55?d=identicon&s=25 Li C. (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.....

Thanks,

Li
9627ec27e4fb3a18be02133b4ddaa901?d=identicon&s=25 Joel P. (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.
98a99a727615dfffe04a65db0915dd55?d=identicon&s=25 Li C. (alex-osu3)
on 2014-04-28 02:00
Thank you Joel.
98a99a727615dfffe04a65db0915dd55?d=identicon&s=25 Li C. (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.
E415967407a77187c7c588dcfeebfc61?d=identicon&s=25 Ed G. (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.
Ed
This topic is locked and can not be replied to.