From: Robert Dober Date: 2006-08-19T17:09:21+09:00 Subject: Re: Bug in sprintf? ------=_Part_17139_18987755.1155974960182 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: quoted-printable Content-Disposition: inline On 8/19/06, Hal Fulton wrote: > > Hal Fulton wrote: > > Carlos wrote: > > > >> > >> For that conversion, #to_i could have been used as well, and then '09' > >> would > >> be interpreted as decimal 9. Why should I expect my string to be passe= d > >> through Integer() before formatting? That is not documented. > >> > > > > Why would you pass a string to something that expects a number > > anyway? > > Actually, let me say this, as it's more informative and > constructive. > > If you need to convert your string to a number, it's best > to do so explicitly. (If you really want to pass a string > into sprintf, %s is the correct modifier.) > > Also note that while Integer() doesn't convert the way > you want, to_i does: > > Integer("09") # error > "09".to_i # 9 > > > Cheers, > Hal > > > Hal all you are saying is true BUT I do not think we should blame C for something which really is not nice. I know not many share my opinion but the brave speaks out nevertheless ;) IMHO the interpreter should raise an expression when a String is passed to %d (as you asked OP rightfully not to do so). Early Failure, please, *early*. BTW who is talking about sprintf I am talking about "%" a very rubish construct. Cheers Robert --=20 Deux choses sont infinies : l'univers et la b=EAtise humaine ; en ce qui concerne l'univers, je n'en ai pas acquis la certitude absolue. - Albert Einstein ------=_Part_17139_18987755.1155974960182--