From: David Jacobs Date: 2011-02-24T12:49:29+09:00 Subject: Re: How to inhibit the use of letters and allowing just numbers --4d65d544_b03e0c6_1003 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit Content-Disposition: inline Hi Matt, If you want to check that one variable is referring to a Numeric and not a String, you can do: def foo(input) case input when Numeric process input else puts "You should've entered a number!" end end If you want to filter an Array for only numbers, you can do something like: def foo(inputs) inputs.select {|e| e.is_a? Numeric } end David On Wednesday, 23 February 2011 at 10:38 pm, Matt Victorio wrote: > Hello, > > I started using Ruby few weeks ago and I have a little problem: > > How do I inhibit the user of using numbers instead of letters? > > For exemple, I created a program that asks the user his age, but I want > the user answer it using only numbers, not letters ('10', not 'ten'). > Which command do I use for returning the line 'use just numbers', for > exemple? > > Please, tell me anything, even if it looks 'hard' :P > > Thank you > > -- > Posted via http://www.ruby-forum.com/. > --4d65d544_b03e0c6_1003--