Ok okay... im new here so I didnât know that. So why is pharo complaining then ? -----Original Message----- From: pharo-users-bounces@lists.gforge.inria.fr [mailto:pharo-users-bounces@lists.gforge.inria.fr] On Behalf Of Igor Stasenko Sent: Wednesday, April 24, 2013 8:40 PM To: A friendly place where any question about pharo is welcome Subject: Re: [Pharo-users] Setters for instance variables Class>>method ..... simply a way to show code snippet for a method and to which class it should belong to. Note that this notation is not syntactically correct in smalltalk. On 24 April 2013 21:24, Mohammad Al Houssami (Alumni) <mha53@mail.aub.edu> wrote:
Yes I do have them but without the ">>" signs This is what I have inside the CharacterToken Class
characterData: anObject
characterData := anObject
This is where pharo complains
characterToken := CharacterToken new.
characterToken characterData: AMPERSAND.
It says it doesnât understand characterData though it is defined in the CharacterToken class
The setters and getters were generated by pharo. So im not sure about what the >> is for
From: pharo-users-bounces@lists.gforge.inria.fr [mailto:pharo-users-bounces@lists.gforge.inria.fr] On Behalf Of Luc Fabresse Sent: Wednesday, April 24, 2013 8:10 PM To: A friendly place where any question about pharo is welcome Subject: Re: [Pharo-users] Setters for instance variables
Hi,
2013/4/24 Mohammad Al Houssami (Alumni) <mha53@mail.aub.edu>
Hello again,
If I have an instance variable A in ClassA and I want to use it in ClassB.
If I do the following in ClassB
objectA := ClassA new.
objectA A: "new value for A".
Why doesnât this work? Isnt this calling the setter of A on the objectA ? Pharo doesnât understand it for some reason .
yes.
but a setter is regular method.
did you defined the method in ClassA.
also, by convention method names start with a lowercase.
Example:
Object subclass: #ClassA
iv: 'a'
ClassA>>a: newValue
a := newValue
objA := ClassA new.
objA a: 1
Cheers,
Luc
-- Best regards, Igor Stasenko.