uups,
of course you are right. Thanks!

like this it becomes obvious:

setMethod("[", signature(x = "testClass", i = "ANY", j="ANY"),
        function (x, i, j, ..., drop){
            print("void function")
            NULL
        }
)

Am 08.12.2010 um 13:39 schrieb jim holtman:

> I don't think it is being called twice; you are seeing the return
> value printed out:
> 
>> setClass("testClass",
> +                 representation(a="character"))
> [1] "testClass"
>> 
>> setMethod("[", signature(x = "testClass", i = "ANY", j="ANY"),
> +        function (x, i, j, ..., drop){
> +            print("void function")
> +            return(NULL)
> +        }
> + )
> [1] "["
>> x <- new("testClass")
>> x[1]
> [1] "void function"
> NULL
>> 
> 
> 
> On Wed, Dec 8, 2010 at 6:41 AM, Mark Heckmann <mark.heckmann@gmx.de> wrote:
>> Dear list,
>> 
>> When playing around with the "[" method for S4 classes I noticed that it gets called twice in my example.
>> 
>> setClass("testClass",
>>                 representation(a="character"))
>> 
>> setMethod("[", signature(x = "testClass", i = "ANY", j="ANY"),
>>        function (x, i, j, ..., drop){
>>            print("void function")
>>        }
>> )
>> 
>>> x <- new("testClass")
>>> x[1]
>> [1] "void function"
>> [1] "void function"
>>> x[1,1]
>> [1] "void function"
>> [1] "void function"
>>> x[1,1,1]
>> [1] "void function"
>> [1] "void function"
>>> 
>> 
>> Why is that so? Can someone help me understand the logic behind it?
>> 
>> Thanks,
>> Mark
>> 
>> –––––––––––––––––––––––––––––––––––––––
>> Mark Heckmann
>> Blog: www.markheckmann.de
>> R-Blog: http://ryouready.wordpress.com
>> 
>> ______________________________________________
>> R-help@r-project.org mailing list
>> https://stat.ethz.ch/mailman/listinfo/r-help
>> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
>> and provide commented, minimal, self-contained, reproducible code.
>> 
> 
> 
> 
> -- 
> Jim Holtman
> Data Munger Guru
> 
> What is the problem that you are trying to solve?

–––––––––––––––––––––––––––––––––––––––
Mark Heckmann
Dipl. Wirt.-Ing. cand. Psych.
Celler Straße 27
28205 Bremen
Blog: www.markheckmann.de
R-Blog: http://ryouready.wordpress.com




	[[alternative HTML version deleted]]

