From: Tim Hunter Date: 2007-10-26T01:53:16+09:00 Subject: Re: Change a string to an integer, report an error if the st Randy Kramer wrote: > Can anybody point me to a way to check if a string represents a valid > integer > and then convert it to an integer? > > It is very likely the string will contain leading zeros, and should not > contain any trailing non-numeric characters. > > Per the documentation (pickaxe 2), to_i won't quite do it, it will just > ignore > trailing non-numeric characters. > Check out Kernel#Integer -- Posted via http://www.ruby-forum.com/.