Aug 10, 2007 01:26
Since it seems that nearly everyone else I know occasionally posts code, I think I'd join in*. A puzzle, a puzzle, hooray!
!(Harness class) contortion
|i|
global isNil ifTrue: [i := 0.
global := [i := i + 1.
i < 9 ifTrue: [^i printString]
ifFalse: ['9']]].
^global value
Harness contortion printOn: Transcript.
Harness contortion printOn: Transcript.
(Smalltalk doesn't standardize method declaration syntax because most implementations don't use source files, but I hope it's clear that a bang (!) signals a declaration on the subsequent class at the subsequent selector)
This is verbatim test code except that I've obscured the method and variable names to, er, make it more obscure. Have fun.
* Yes, I'm sure I've done it before, too.
code,
smalltalk