[squeak-dev] Hyphenation puzzle/exercise

Tim Johnson digit at sonic.net
Thu Mar 9 19:55:17 UTC 2023

Hi all,

I was toying with different ways to add hyphens to a string in a 
specific pattern, like for a UUID.  Here's what I came up with:

| s oc |
s := 'eg11dc5cad154625885bc70d4f42818e' readStream.
oc := OrderedCollection new.
#( 8 4 4 4 12 ) do: [:count | oc add: (s next: count)].
oc joinSeparatedBy: $-

"  'eg11dc5c-ad15-4625-885b-c70d4f42818e'  "

Does anyone have any more graceful or clever ways of accomplishing this?


More information about the Squeak-dev mailing list