On Sun, Jun 24, 2012 at 9:20 PM,  <sto.mar / web.de> wrote:
> Am 24.06.2012 20:37, schrieb luke gruber:
>
>>> Here an example method that I use from time to time:
>>>
>>> class String
>>> =A0 =A0def integer?
>>> =A0 =A0 =A0!!(self =3D~ /\A[+-]?[0-9]+\Z/)
>>> =A0 =A0end
>>> end
>>>
>>> Regards,
>>> Marcus
>>
>>
>> Hey, this can be made a bit cleaner by doing:
>>
>> =A0 =A0/regex/ =3D=3D=3D 'string'

Or even

def integer?
  Integer(self) rescue nil
end

Kind regards

robert

--=20
remember.guy do |as, often| as.you_can - without end
http://blog.rubybestpractices.com/