Hi Stefan,
If you create the method definition like this:
Test {
*someTest {arg in; ^in*5}
}
you've created a classmethod which you can run with:
Test.someTest(10) //returns 50
If you want to use an instance method you need to create an instance
of Test:
a = Test.new; //create an instance of Test
Then you can use the method for that object:
a.someTest(10) //returns 50
The reason that the example you posted doesn't work is that the number
10 is in fact an instance of Integer ( 10.class.postln ), not an
instance of Test. This gives you access to Integers method, and the
methods of Integers superclasses.
-Eirik
Den 12. mai. 2008 kl. 18.33 skrev Stefan Nussbaumer:
> sorry, probably i'm missing something ...
>
> i have this class-definition:
>
> Test {
>
> someTest { arg in; ^in*5 }
>
> }
>
> after having recompiled i'm trying to execute this:
>
> 10.someTest.postln
>
> shouldn't that post 50? i'm just getting an error: ERROR: Message
> 'somTest' not understood (and some other lines ...).
>
>
> i've read through the writing classes help and i've written a couple
> of
> class methods that work the way they are supposed to. what am i
> missing
> about instance methods?
>
> thanks for any help
>
> stefan
> _______________________________________________
> sc-users mailing list
>
sc-users@...
>
http://lists.create.ucsb.edu/mailman/listinfo/sc-users_______________________________________________
sc-users mailing list
sc-users@...
http://lists.create.ucsb.edu/mailman/listinfo/sc-users