3 ms·
A couple of minor nits: - is_int? is rather misleading (I would not expect is_int?(1.2) to be true) - Since Ruby ints are truthy, the idiomatic form would pro
by pmh 13y ago
A couple of minor nits:
- is_int? is rather misleading (I would not expect is_int?(1.2) to be true)
- Since Ruby ints are truthy, the idiomatic form would probably just return Integer(x) and false or nil otherwise:
def is_int?(x)
Integer(x) rescue false
end
- maurycy 13y agos/is_int/intable/ ;-)
- Aaronneyer 13y agoAh you're right. Hadn't actually tested this. The way that I've actually used it is for `is_num?` and using `Float()`. I didn't consider the fact that `Integer` would cast a float.