From: Robert Klemme Date: 2003-11-17T10:23:29+09:00 Subject: Re: to_i "Artur Merke" schrieb im Newsbeitrag news:Pine.LNX.4.33.0311101726040.17966-100000@as0203.cs.uni-dortmund.de... Hi, taken from the ruby book: str.to_i -> anInteger Returns the result of interpreting leading characters in str as a decimal integer. Extraneous characters past the end of a valid number are ignored. If there is not a valid number at the start of str, 0 is returned. The method never raises an exception. example "hello".to_i � 0 Is there a way to recognize if the conversion was successful? If "0".to_i and "any string".to_i deliver the same result, I don't see how this could be accomplished, without separately checking the syntax of the given string. Why doesn't "hello".to_i deliver a nil as a return value, which can clearly be recognized as a conversion failure? 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. Kind regards robert