Simple input problem

Hello all,

  Somehow the following always worked for me before, but tonight, it
failed, and I don't understand why:

gets a

It's a simple gets command! For some reason when I press Enter, the
cursor just stays there, waiting for more input. What can this be?
Also, I can't do gets a, if I haven't assigned a value to a yet. How is
that possible? I thought I could use ruby variables without declaring
them first! Please help, it's frustrating to get stuck on something so
basic!

···

--
Posted via http://www.ruby-forum.com/.

Omar Campos wrote:

Hello all,

  Somehow the following always worked for me before, but tonight, it
failed, and I don't understand why:

gets a

It's a simple gets command! For some reason when I press Enter, the
cursor just stays there, waiting for more input. What can this be?
Also, I can't do gets a, if I haven't assigned a value to a yet. How is
that possible? I thought I could use ruby variables without declaring
them first! Please help, it's frustrating to get stuck on something so
basic!

Never mind! I was doing it wrong, it is

a = gets

!!

···

--
Posted via http://www.ruby-forum.com/\.

Hi,

···

Am Freitag, 18. Dez 2009, 12:18:03 +0900 schrieb Omar Campos:

Omar Campos wrote:
>
> gets a
>
Never mind! I was doing it wrong, it is

a = gets

Be aware that `gets' will return `nil' when the user presses
Ctrl-D. Saying

  gets.chomp

will raise an exception then.

Bertram

--
Bertram Scharpf
Stuttgart, Deutschland/Germany
*
Discover String#notempty? at <http://raa.ruby-lang.org/project/step&gt;\.

Thanks, I will keep that in mind.

···

--
Posted via http://www.ruby-forum.com/.