# Input before Output in Eclipse

**URL:** <https://www.ruby-forum.com/t/input-before-output-in-eclipse/61729>\
**Category:** Ruby\
**Created:** [May 26, 2006, 5:12pm UTC](https://www.ruby-forum.com/t/input-before-output-in-eclipse/61729 "2006-05-26T17:12:39Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![yoche2001](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/y/57b2e6/32.png) [@yoche2001](https://www.ruby-forum.com/u/yoche2001)\
**Post date:** [May 26, 2006, 5:12pm UTC](https://www.ruby-forum.com/t/input-before-output-in-eclipse/61729/1 "2006-05-26T17:12:39Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![yoche2001](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/y/57b2e6/32.png) [@yoche2001](https://www.ruby-forum.com/u/yoche2001)\
**Post date:** [May 26, 2006, 5:27pm UTC](https://www.ruby-forum.com/t/input-before-output-in-eclipse/61729/2 "2006-05-26T17:27:20Z")

</div>

On Friday 26 May 2006 11:12, Yochen G. 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

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

---

<div class="post-metadata">

**Author:** ![yoche2001](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/y/57b2e6/32.png) [@yoche2001](https://www.ruby-forum.com/u/yoche2001)\
**Post date:** [May 26, 2006, 5:30pm UTC](https://www.ruby-forum.com/t/input-before-output-in-eclipse/61729/3 "2006-05-26T17:30:00Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![yoche2001](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/y/57b2e6/32.png) [@yoche2001](https://www.ruby-forum.com/u/yoche2001)\
**Post date:** [May 26, 2006, 5:40pm UTC](https://www.ruby-forum.com/t/input-before-output-in-eclipse/61729/4 "2006-05-26T17:40:08Z")

</div>

On Friday 26 May 2006 11:30, Yochen G. 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

---

<div class="post-metadata">

**Author:** ![yoche2001](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/y/57b2e6/32.png) [@yoche2001](https://www.ruby-forum.com/u/yoche2001)\
**Post date:** [May 26, 2006, 5:55pm UTC](https://www.ruby-forum.com/t/input-before-output-in-eclipse/61729/5 "2006-05-26T17:55:20Z")

</div>

Simon KrÃ¶ger wrote:

> $stdout.sync = true
> 
> might fix it.

Indeed, my friend, this really solved the problem!

Thanx a lot.

Greetings,  
Yoche

---

<div class="post-metadata">

**Author:** ![yoche2001](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/y/57b2e6/32.png) [@yoche2001](https://www.ruby-forum.com/u/yoche2001)\
**Post date:** [May 26, 2006, 5:53pm UTC](https://www.ruby-forum.com/t/input-before-output-in-eclipse/61729/6 "2006-05-26T17:53:03Z")

</div>

James F. Hranicky schrieb:

> 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
