Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

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


Ah 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.


s/is_int/intable/ ;-)




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: