Hi

Just to share with you guys.

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.

If you are using Float("ss") or Integer("5"). It will work but unluckly 
it might crash your program which happen with me. and to avoid that you 
need to use exception which will enlarge your code.

so just to list the ways down
to check datatypes you can use

x = "name"
y = 5

1.
x.class => String
y.class => Float

2.
Integer(y) => 5
Float(y) => 5.0

3.

y.is_a? Integer => true
x.is_a? String => true
y.is_a? Float => flase

Cheers

This forum is a continuous learning platform and is very helpful.



-- 
Posted via http://www.ruby-forum.com/.