From: pere.noel@... (=?ISO-8859-1?Q?Une_b=E9vue?=) Date: 2006-07-11T03:45:05+09:00 Subject: Re: Real newbie question about methods simonh wrote: > It seems I didn't need the parameter to the method. Also forgot to add > the second elsif (to check if too old). If I run the program and type > 'a' instead of a two digit number the first if statement gets printed - > 'sorry too young' > > what i want is for the else statement to be run if user input is not > entered as two digits. How would I do this? Somehow got to check if > gets recieves an integer of two digits. def check_age print "Please enter your age: " age = gets.chomp.to_i eligible = 18..30 if age == 0 print "Please enter a two digits number in � 18..30 �." check_age elsif eligible === age print "Have a great holiday!" else age < 18 print "Sorry, too young." end end check_age the "gets.chomp.to_i" returns 0 when only alphabetic chars. ie : "toto" => 0 or : "blahblah27yyyiyiyiyui" => 0 -- une b�vue