[squeak-dev] The Inbox: Collections-hk.360.mcz

Herbert König herbertkoenig at gmx.net
Thu May 20 18:29:28 UTC 2010


Hello Frank,


FS> Isn't the problem that the caller wants to know that some string 
FS> contains a number (in base 10, presumably)?

no, it's deeper, a number may have sign, decimal separator .....

FS> It seems perfectly sensible that '' isAllDigits returns true - because
FS> it's vacuously true.

The change arose from the fact that I have written:

(aString notEmpty and: [aString isAllDigits]) if True: []

in various applications for e.g. 10 being valid for 10 o'clock or -,4
being a valid float.

FS> So shouldn't there be (and I haven't looked for existing functionality)
FS> something like String>>isNumeric which says self isEmpty and: [self
FS> isAllDigits] ?

Something like that would be my next resort, but "isNumeric" is
misleading as it's also true for '-3'.

FS> I'm torn between my sense of logic and my desire to avoid bikeshedding.

The reason to discuss it is, it might break existing code. My logic
would be that isAllDigits is a pointed form of isDigits and
'' isDigits is undoubtedly false (or so I hope).

At least I found a good name if I have to add yet another method to
String.



Cheers,

Herbert




More information about the Squeak-dev mailing list