Does Rails 3 or Ruby have a built-in way to check if a variable is an integer?
For example,
1.is_an_int #=> true "[email protected]".is_an_int #=> false?
You can use the is_a? method
is_a?
>> 1.is_a? Integer => true >> "[email protected]".is_a? Integer => false >> nil.is_a? Integer => false
1.4m articles
1.4m replys
5 comments
57.0k users