help-smalltalk
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Help-smalltalk] I found two errors in the gnu-smalltalk tutorial


From: adam
Subject: [Help-smalltalk] I found two errors in the gnu-smalltalk tutorial
Date: Fri, 14 Mar 2014 14:02:55 -0400

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.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]