How to check if a variable is a number or a string in Ruby?
There are several ways:
>> 1.class #=> Fixnum >> "foo".class #=> String >> 1.is_a? Numeric #=> true >> "foo".is_a? String #=> true
1.4m articles
1.4m replys
5 comments
57.0k users