Hi! No TOFU (Text on-top of full quote) please, thank you. * Artur Merke; 2003-11-19, 13:45 UTC: > you don't really want to compare ruby with c! BTW, what you have > overlooked is the fact, that c doesn't have a nil return value (0 > is only a nil value in connection with pointers, not integers), so > Kernighan & Richie havn't had another option then to return 0, but > in ruby you have a nil value, and I'm pretty sure ;-), K&R would > have chosen to return nil in ruby's to_i method. They wouldn't because nil is an instance of NilClass not an instance of String. It would be a big surprise if a method sometimes returns this class and sometimes returns that class (unless of course one class is a subclass of the other one or both classes have a common superclass). I therefore expect to_i to behave like to_s, the latter defaulting to "" if no senseful representation is being found. If to_s returns string version of nothing in such cases it would be a big surprise if to_i would not return the numerical version of nothing - which is 0. The obvious alternative to returning something unexpected is to raise an exception indicating that something unexpected was encountered. It would make perfect sense if to_i would raise an ArgumentError. For this reason there are *two* ways of convering strings to numbers. - Sending the to_i message is the non-exception-throwing variant. - Applying the Integer operator is the exception-throwing variant. Just my 0.02 EUR, Josef 'Jupp' Schugt -- .-------. message > 100 kB? / | | sender = spammer? / | R.I.P.| text = spam? / ___| |___