I found two errors in the gnu-smalltalk tutorial

Previous Topic Next Topic
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view

I found two errors in the gnu-smalltalk tutorial

Here are my notes:


*The following is missing the opening square bracket after the `aBlock'
parameter, and an associated closing bracket after the function body.

Checking extend [
            checksOver: amount do: aBlock
                history keysAndValuesDo: [:key :value |
                    (value > amount)
                           ifTrue: [aBlock value: key]


The following code would not run:

     Checking extend [
         writeCheck: amount
            | num |

            (checksleft < 1)
                ifTrue: [ ^self error: 'Out of checks' ].
            num := checknum.
            checknum := checknum + 1.
            checksleft := checksleft - 1.
            self spend: amount
            ^ num

Fixed via the following changes:

`writeCheck: amount  ['    ---- was missing the opening square bracket.
`self spend: amount.'     ---- needs a period at the end of the statement.

This was difficult for me to spot because the structure of the code becomes
more apparent after code blocks are introduced.
help-smalltalk mailing list
[hidden email]