[Newbies] Drawing a line on a morph
Bert Freudenberg
bert at freudenbergs.de
Fri Oct 30 18:00:20 UTC 2009
On 30.10.2009, at 11:52, Christine Wolfe wrote:
> drawOn: aCanvas
> super drawOn: aCanvas.
> (self perform: ('face', dieValue asString) asSymbol)
> do: [{:aPoint, anotherPoint} | self drawLineOn: aCanvas from: aPoint
> to: anotherPoint]
In my version of Squeak this won't even compile.
How did you accept that method?
The curly-bracket array notation can not be used to extract multiple
arguments. Instead, you would have to do something like this:
[:aPointPair | self drawLineOn: aCanvas from: aPointPair first to:
aPointPair second]
And secondly, this expression is valid syntactically but does not do
what you might expect:
> face1
> ^{{2 at 2, 2 at 10}, {2 at 2, 10 at 2}, {10 at 10, 2 at 10}, {10 at 10, 10 at 2}}
In non-literal Array notation, expressions must be separated by
periods, not commas:
{{2 at 2. 2 at 10}. {2 at 2. 10 at 2}. {10 at 10, 2 at 10}. {10 at 10. 10 at 2}}
The way you would verify a line like this or your's above is you
simply select it and press cmd-p so it will print the result. You can
do this in any browser or workspace.
- Bert -
More information about the Beginners
mailing list