A very basic question

Hi…plz reply to this very basic question.

What is the syntax(function) for taking user input(numbers not strings )
in
ruby.

Thanks in advance.

Tanushree

On 15/06/06, Tanushree B. [email protected] wrote:

What is the syntax(function) for taking user input(numbers not strings ) in
ruby.

gets() returns Strings because that’s how console i/o works,
but you can convert that to an number with String#to_i .

irb>
irb(main):001:0> require ‘scanf’
=> true
irb(main):004:0> scanf("%d %s")
1 lemon
=> [1, “lemon”]

Thanks Dick.

Thanks Joey for your reply.
But when i am writting like this in my ruby irb.
scanf("%d %s")
its not responding.For require ‘scanf’ its giving ‘true’.
I am using ruby 184-16.

Thanks

Tanushree

Yeah i know that Matthe.
I am entering values.

On Jun 15, 2006, at 14:06, Tanushree B. wrote:

Thanks Joey for your reply.
But when i am writting like this in my ruby irb.
scanf("%d %s")
its not responding.

It’s an input method - are you entering anything?

matthew smillie.

-----Original Message-----
From: Tanushree B. [mailto:[email protected]]

But when i am writting like this in my ruby irb.
scanf("%d %s")
its not responding.

On 6/15/06, Matthew S. [email protected] wrote:
It’s an input method - are you entering anything?
[…]
Yeah i know that Matthe.
I am entering values.

OK, now try hitting ‘enter’.

ben