From: "studlee2@..." Date: 2006-07-11T04:50:05+09:00 Subject: Re: Real newbie question about methods Agreed that the regexp wouldn't work for your code. I would have written it like this (like I said before your code is cleaner) def check_age print "Please enter your age: " age = gets.chomp target = 18..30 valid = /\d{2}/ if valid.match(age) if target === age.to_i puts 'Have A Nice Holiday' elsif age.to_i < 18 puts 'Too Young' elsif age.to_i > 30 puts 'Too Old' end else puts "Usage: <18..30>" check_age # Try again end end check_age _Steve Une b�vue wrote: > studlee2@gmail.com wrote: > > > valid = /\d{2}/ #checks for exactly 2 digits > > this woundn't help because of gets.chomp returns always strings and > gets.chomp.to_i returns Fixnum with 0 in case of any alpha betic char in > gets... > -- > une b�vue