hello i have class with two setters phone1: aValue phone2: aValue
and i want call it dynamically aSelector is phone1 or phone2 string
setPhohne: aSelector by: aValue
phoneBook perform aSelector, ':' aValue
but this is not working how can i do this when i try this iwth getters it works fine
Transcript show: (phoneBook perform aSelector); cr.
Hi Jakub,
#perform: is for unary message
If you want to pass arguments you have to use #perform:with: "On argument" #perform:with:with: "Two arguments" .. #perform:withArguments: "Several arguments inside an Array"
so in your case it should be:
phonebook perform: #phone1 with: aValue
HTH
On Jan 14, 2008, at 2:58 PM, Jakub wrote:
hello i have class with two setters phone1: aValue phone2: aValue
and i want call it dynamically aSelector is phone1 or phone2 string
setPhohne: aSelector by: aValue
phoneBook perform aSelector, ':' aValue
but this is not working how can i do this when i try this iwth getters it works fine
Transcript show: (phoneBook perform aSelector); cr.
-- Jakub. _______________________________________________ Beginners mailing list Beginners@lists.squeakfoundation.org http://lists.squeakfoundation.org/mailman/listinfo/beginners
Mth
And, instead of concatenating your selector with ':', you can send a symbol the message #asMutator (which does it for you).
For example:
#phone1 asMutator "prints #phone1:" #phone2 asMutator "prints #phone2:"
Which you can use like this:
phoneBook perform: aSelector asMutator with: aValue
Regards, Zulq.
Mathieu Suen wrote:
Hi Jakub,
#perform: is for unary message
If you want to pass arguments you have to use #perform:with: "On argument" #perform:with:with: "Two arguments" ... #perform:withArguments: "Several arguments inside an Array"
so in your case it should be:
phonebook perform: #phone1 with: aValue
HTH
On Jan 14, 2008, at 2:58 PM, Jakub wrote:
hello i have class with two setters phone1: aValue phone2: aValue
and i want call it dynamically aSelector is phone1 or phone2 string
setPhohne: aSelector by: aValue
phoneBook perform aSelector, ':' aValue
but this is not working how can i do this when i try this iwth getters it works fine
Transcript show: (phoneBook perform aSelector); cr.
-- Jakub. _______________________________________________ Beginners mailing list Beginners@lists.squeakfoundation.org http://lists.squeakfoundation.org/mailman/listinfo/beginners
Mth
beginners@lists.squeakfoundation.org