If you do: Number readFrom: '3foo'. --> exception Number readFrom: '3foo' readStream --> 3
String#asNumber is defined as ^Number readFromString: self And #readFromString: does the readStream. They are two different things. What Integer>>readFrom: does and what String>>asNumber does. String>>asNumber should fail :). On Thu, Aug 26, 2010 at 9:43 AM, Johan Brichau <[email protected]> wrote: > > On 25 Aug 2010, at 09:26, Stéphane Ducasse wrote: > >>> Did you mean to let the dirty stuff to #squeezeOutNumber and throw the >>> error in the #readFrom:? >> >> Yes. Now we should identify user of readFrom: that in fact are expecting >> squeezeOutNumber and fix them. > > Well, it seems that the current readFrom: only requires the string to _start_ > with a valid format. This means that: > > '3foo' asInteger = 3 > > Should we not fail here too? What are the opinions? > > Johan > _______________________________________________ > Pharo-project mailing list > [email protected] > http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project > _______________________________________________ Pharo-project mailing list [email protected] http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project
