From: Austin Ziegler Date: 2003-11-17T13:23:20+09:00 Subject: Re: to_i On Mon, 17 Nov 2003 10:24:58 +0900, Artur Merke wrote: >> IMHO this is a struggle between convenience and cleanness. I guess >> Matz decided for convenience in this case, maybe because in most cases >> using 0 is ok. If you want to do correct input checking you do /^[+- >> ]?\d+$/ =~ foo anyway. >> > IMO, it has to do with the principle of least surprise, and it is a BIG > surprise to get "hello".to_i -> 0 http://www.cplusplus.com/ref/cstdlib/atoi.html It is common for integer conversion techniques to use only what is known (e.g., "123hello" => 123; "hello" => 0). Delphi's StrToInt method, however, will throw an error (in some silly cases, IMO). -austin -- austin ziegler * austin@halostatue.ca * Toronto, ON, Canada software designer * pragmatic programmer * 2003.11.16 * 23.21.40