From: Josef 'Jupp' SCHUGT Date: 2003-11-18T06:46:49+09:00 Subject: Re: to_i Hi! * Artur Merke; 2003-11-17, 14:20 UTC: > IMO, it has to do with the principle of least surprise, and it is a > BIG surprise to get > "hello".to_i -> 0 Let me quote Kernighan & Richie, Programming in C (naive implementation of atoi): int atoi(char s[]) { int i, n; n = 0; for (i = 0; s[i] >= '0' && s[i] <= '9'; ++i) n = 10 * n + (s[i] - '0'); return n; } Assuming this sample implementation it is not at all surprising that atoi returns 0 if the argument string does not start with a 'digit'. Given Ruby's C heritage it is no surprise that to_i behaves the same as atoi. Josef 'Jupp' Schugt -- .-------. message > 100 kB? / | | sender = spammer? / | R.I.P.| text = spam? / ___| |___