Error in the code

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

Error in the code

ZuLuuuuuu
Hello,

I couldn't find the problem with this code:


Object subclass: Animal [
        | noise |

        setNoise: noise [
                "An instance method to set the animals noise."
                <category: 'accessing'>

                self noise := noise.

                ^self noise
        ]
]


It gives this error: deneme.st:8: parse error, expected ']'

Sorry if the mistake is too obvious :)



_______________________________________________
help-smalltalk mailing list
[hidden email]
http://lists.gnu.org/mailman/listinfo/help-smalltalk
Canol Gökel
Reply | Threaded
Open this post in threaded view
|

Re: Error in the code

Paolo Bonzini-2

> I couldn't find the problem with this code:
>
> Object subclass: Animal [
> | noise |
>
> setNoise: noise [
> "An instance method to set the animals noise."
> <category: 'accessing'>
>
> self noise := noise.
>
> ^self noise
> ]
> ]
>
>
> It gives this error: deneme.st:8: parse error, expected ']'
>
> Sorry if the mistake is too obvious :)

If you want, I'll tell you.  But you should really follow the tutorial.

Paolo


_______________________________________________
help-smalltalk mailing list
[hidden email]
http://lists.gnu.org/mailman/listinfo/help-smalltalk
Reply | Threaded
Open this post in threaded view
|

Re: Error in the code

ZuLuuuuuu
Paolo Bonzini <bonzini <at> gnu.org> writes:

>
>
> If you want, I'll tell you.  But you should really follow the tutorial.
>
> Paolo
>


Ok then, I'll try to find out the mistake by tomorrow night but if I can't then
you tell me :)



_______________________________________________
help-smalltalk mailing list
[hidden email]
http://lists.gnu.org/mailman/listinfo/help-smalltalk
Canol Gökel
Reply | Threaded
Open this post in threaded view
|

Re: Re: Error in the code

Paolo Bonzini-2
Canol Gokel wrote:

> Paolo Bonzini <bonzini <at> gnu.org> writes:
>
>>
>> If you want, I'll tell you.  But you should really follow the tutorial.
>>
>> Paolo
>>
>
>
> Ok then, I'll try to find out the mistake by tomorrow night but if I can't then
> you tell me :)

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

You will have found out by tomorrow night (and by then I'll be on a
plane to my holidays so I can't tell you :-)

Paolo


_______________________________________________
help-smalltalk mailing list
[hidden email]
http://lists.gnu.org/mailman/listinfo/help-smalltalk
Reply | Threaded
Open this post in threaded view
|

Re: Error in the code

ZuLuuuuuu
In reply to this post by ZuLuuuuuu
Canol Gokel <canol <at> canol.info> writes:

>
> Ok then, I'll try to find out the mistake by tomorrow night but if I can't then
> you tell me :)
>


If I correctly understand, I shouldn't write "self" before "noise". Because it
automatically gets the instance variable noise.

But it prevents me creating message arguments named same as some instance
variables. For example, in this case I cannot create messages with arguments
named "noise".

But I can do create local variables called "noise" in methods.



_______________________________________________
help-smalltalk mailing list
[hidden email]
http://lists.gnu.org/mailman/listinfo/help-smalltalk
Canol Gökel
Reply | Threaded
Open this post in threaded view
|

Re: Error in the code

ZuLuuuuuu
In reply to this post by Paolo Bonzini-2
Paolo Bonzini <bonzini <at> gnu.org> writes:

>
> http://www.gnu.org/software/smalltalk/manual/html_node/Tutorial.html
>
> You will have found out by tomorrow night (and by then I'll be on a
> plane to my holidays so I can't tell you
>
> Paolo
>


If you ever come to Turkey for holiday then let me know and we may have a
Turkish coffee together ;) Happy holidays...



_______________________________________________
help-smalltalk mailing list
[hidden email]
http://lists.gnu.org/mailman/listinfo/help-smalltalk
Canol Gökel