From: "studlee2@..." Date: 2006-07-11T03:50:10+09:00 Subject: Re: Real newbie question about methods One correction: make age a string (.to_s) if you want to use the regexp >_< I think Une's code is cleaner overall. _Steve studlee2@gmail.com wrote: > You can add a regular expression to see if you age is valid like this: > > /-----------------------------------------------------------------/ > valid = /\d{2}/ #checks for exactly 2 digits > if valid.match(age.to_s) > > > > else > puts "Invalid entry" > end > > /-----------------------------------------------------------------/ > Hope this helps. > > _Steve > > > simonh wrote: > > Thanks Une b�vue > > > > 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. > > > > thanks again