From: John Joyce Date: 2007-11-02T04:12:43+09:00 Subject: Re: Can we define data types explicitly? On Nov 1, 2007, at 1:47 PM, Sebastian Hungerecker wrote: > Shuaib Zahda wrote: >> After trying several ways of checking the data types of my input. I >> found that the best method to be used is is_a? or kind_of? because it >> returns true or false value. In my case, this is best. > > User input will always be a string until you convert it. > user_input = gets > user_input.is_a? Integer > Will never be true - even if the user enters a number. > Oh really?! Perhaps if it comes from a keyboard and stdin, yes. What about other input devices ?? Mouse, Joystick/joypad, Stylus, Light pen, other types of sensors (heat, pressure, wind speed...) Changing input routines? There is no reason input could not be any other class in Ruby, including nil.