--huq684BweRXVnRxX
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable
I don't like the default behavior of String#to_i and String#to_f to return
zero for any string that contains no recognizable numbers. I had thought to
write overriding methods like so:
Class String
def to_i
fail "#{self} is not a valid integer" unless self =~ /^\d*$/
# call original to_i
end
end
...but I don't how (if it is possible?) to call the original to_i. Am I stuck
with using a new method name or a custom string class?
--
Henry House
OpenPGP key available from http://romana.hajhouse.org/hajhouse.asc
--huq684BweRXVnRxX
Content-Type: application/pgp-signature
Content-Disposition: inline
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.6 (GNU/Linux)
Comment: For info see http://www.gnupg.org
iD8DBQE7loDpKK1cAVjXujwRAtxnAJ9JBvXIK6zTa3fn4fAv4T5e+d4eogCg7DLo
89ZFFTsTlZeD3UjfxOgnsA0¿¹u
-----END PGP SIGNATURE-----
--huq684BweRXVnRxX--