From: Ulrich Holtzhausen Date: 2009-01-12T07:15:17+09:00 Subject: Checking if input == Integer/String? Hi, I'm all new to programming and all new to Ruby - hope I haven't made a mistake by choosing this language. I'm trying to teach myself by creating tiny (mostly useless) little applications and then extend on them as I learn. Today I started out and this is what I got: #!/usr/bin/env ruby #Favourite number puts "What is your favourite number?" num = gets.to_i if num != Integer puts "Please type a number" else better = num + 1 puts "Hah! #{num} is pathetic! #{better} is a much better number!!!" end Somewhere along the line there's a mistake however, but I take it you guru's can see what I'm trying to do here? How can I check if the variable 'num' is an integer and if not, ask the user to re-input with an integer? Thanks in advance! -- Posted via http://www.ruby-forum.com/.