[ENH] asDigitVersion

Andreas Raab andreas.raab at gmx.de
Sun Mar 28 15:52:20 UTC 2004


Or simpler:

String>>asDigitVersion: nDigits
    ^self padded: #left to: nDigits with: $0

Btw, I'm *really* missing a test for the boundary conditions in:

    '11111' asDigitVersion: 2.

Does it raise an error? Does it silently truncate? Does it leave the
receiver unaffected?

Cheers,
  - Andreas

----- Original Message ----- 
From: <ducasse at iam.unibe.ch>
To: <squeak-dev at lists.squeakfoundation.org>
Sent: Sunday, March 28, 2004 4:11 PM
Subject: [ENH] asDigitVersion


> from preamble:
>
> "Change Set: asDigitVersion
> Date: 28 March 2004
> Author: stéphane ducasse
>
> to generate version string based on a size
>
> testAsDigitVersion
> self assert: ('1' asDigitVersion: 3) = '001'.
> self assert: ('111' asDigitVersion: 3) = '111'.
> self assert: ('111' asDigitVersion: 4) = '0111'.
> self assert: ('111' asDigitVersion: 2) = '111'.
>
> "!
>


----------------------------------------------------------------------------
----


>
>




More information about the Squeak-dev mailing list