Testing if a String is a number
Damien Cassou
damien.cassou at laposte.net
Wed Jul 5 11:35:02 UTC 2006
ncellier at ifrance.com wrote:
> However, there are two details:
>
> 1) maybe you have to care about separators
> for example ' 10' is Number will be true, while '10 ' isNumber will be false
> think of changing ^stream skipSeparators; atEnd
Thank you for this precision. I can strip the string too.
> 2) the #isNumber method name is questionnable
> Current implementation in virgin images is a short cut of (isKindOf: Number),
> Most senders of isNumber will really expect a Number, not a String
> try (2 * '4') or ('3.14' sin) in your image, and you will see what i mean.
I've noticed this and change the name in my previous mail to
#stringIsNumber.
Thank you
More information about the Squeak-dev
mailing list
|