Hi Rubyfolks,
I've just started to learn ruby, using Eclipse and RDT as IDE (on Mac).
One of my first program was the following (don't laugh!):
print "Whats your name? "
name = gets
print "Your name is: "+name
Not very complicated, hm? Nevertheless, it refused to work in the
expected way: Nothing happened. After some useless thinkining I madly
stroke my keyboard and suddenly there appeared:
lk,dfsnlvihols
Whats your name?
Your name is: lk,dfsnlvihols
So it seemed as if ruby was first waiting for the input (gets) and then
printing "Whats your name?". This really drove me crazy. After searching
many books and articles no clue was found. In my desparation I just went
to the terminal (the Mac-text-console) and started the little program by
hand. And voila! It Worked!
So since I still want to use Eclipse for development could someone gimme
a hint how to change eclipse'/ruby's/RDT's behabiour?
Thanks!
Yoche
···
--
Posted via http://www.ruby-forum.com/.
print doesn't output newlines, puts does. Try this:
puts "Whats your name? "
name = gets
puts "Your name is: "+name
Due to output buffering, output without a newline is sometimes not
printed right away.
Jim
···
On Friday 26 May 2006 11:12, Yochen Gutmann wrote:
Hi Rubyfolks,
I've just started to learn ruby, using Eclipse and RDT as IDE (on Mac).
One of my first program was the following (don't laugh!):
print "Whats your name? "
name = gets
print "Your name is: "+name
Hi Jim,
James F. Hranicky wrote:
print doesn't output newlines, puts does. Try this:
puts "Whats your name? "
name = gets
puts "Your name is: "+name
Due to output buffering, output without a newline is sometimes not
printed right away.
Thank you for your fast response.
Well, I thought of output buffering, too and tries puts. But still:
wrong order...To me it seems an Eclipse console problem..
Any other suggestion?
Greetings from Berlin,
Yoche
···
--
Posted via http://www.ruby-forum.com/\.
Interesting -- unfortunately I don't have any experience with the eclipse
console, so if it's not working like a regular shell I wouldn't know why,
sorry.
Jim
···
On Friday 26 May 2006 11:30, Yochen Gutmann wrote:
Thank you for your fast response.
Well, I thought of output buffering, too and tries puts. But still:
wrong order...To me it seems an Eclipse console problem..
Any other suggestion?
James F. Hranicky schrieb:
···
On Friday 26 May 2006 11:30, Yochen Gutmann wrote:
Thank you for your fast response.
Well, I thought of output buffering, too and tries puts. But still:
wrong order...To me it seems an Eclipse console problem..
Any other suggestion?
Interesting -- unfortunately I don't have any experience with the eclipse
console, so if it's not working like a regular shell I wouldn't know why,
sorry.
Jim
$stdout.sync = true
might fix it.
cheers
Simon
Simon Kröger wrote:
$stdout.sync = true
might fix it.
Indeed, my friend, this really solved the problem!
Thanx a lot.
Greetings,
Yoche
···
--
Posted via http://www.ruby-forum.com/\.