Testing if a String is a number
Damien Cassou
damien.cassou at laposte.net
Wed Jul 5 08:24:40 UTC 2006
ncellier at ifrance.com wrote:
> I suggest you use my Squeak NumberParser (See http://bugs.impara.de/view.php?id=3512 ) which has error handling a little bit more developped than just answering zero...
>
> You could simply test is aNumber is read without error from (self readStream), and assert the stream atEnd.
Your parser works perfectly. Now, #stringIsNumber should be implemented as:
stringIsNumber
| stream |
stream _ self readStream.
SqNumberParser parse: stream onError: [^ false].
^ stream atEnd
Next line is a subliminal message, don't read it please !
It would be cool to have it in the base image, please include it
Thank you
More information about the Squeak-dev
mailing list
|