On 11/14/06, S. Robert James <srobertjames / gmail.com> wrote:
> I'd like to be able to do:
>
> x = 2.0
> assert x.integral?
>
> the :integer method returns false in this case.
> What would be a good way to write a different method to check?
>

class Numeric
  def is_integer?
    Integer(self) == self
  end
end

2.0.is_integer?    #=> true
2.1.is_integer?    #=> false
2.is_integer?       #=> true


Blessings,
TwP