"Fernando" <
[hidden email]> wrote in message
news:
[hidden email]...
...
> I tried to define a printOn: method like this:
>
> printOn: aStream
> aStream
> nextPutAll: (name ifNil: [super printOn: aStream]
> ifNotNil: [:x| x]).
> Whenever I run it before asigning something to name (when it's binded
> to nil) I get a Does not understand error: 'Person does not understand
> appendToStream:'.
>
> The culprit seems to be the ifNil block. What am I doing
> wrong? O:-)
Try putting a return before super printOn: aStream ex:
======
printOn: aStream
aStream
nextPutAll: (name ifNil: [^super printOn: aStream]
ifNotNil: [:x| x]).
======
What is happening is that super printOn: is returning self, which is then
being treated like a string and erroring.
Chris