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
2.1m questions
2.1m answers
60 comments
57.0k users