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

adam
Here are my notes:

http://www.gnu.org/software/smalltalk/manual/html_node/Invoking-code-blocks.html#Invoking-code-blocks

*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]
                ]
        ]


http://www.gnu.org/software/smalltalk/manual/html_node/Conditions.html#Conditions

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]
https://lists.gnu.org/mailman/listinfo/help-smalltalk