From hpages at fhcrc.org  Mon Oct  2 21:21:31 2006
From: hpages at fhcrc.org (Herve Pages)
Date: Mon, 02 Oct 2006 12:21:31 -0700
Subject: [Rd] More strange [[ behaviour
Message-ID: <452166BB.3040901@fhcrc.org>

Hi,

> setClass("MyList", "list")
[1] "MyList"
> a <- new("MyList")
> a
An object of class "MyList"
list()
> setMethod("[[", "MyList", function(x, i, j, ...) cat("Just testing\n"))
> a[[]]
Just testing
> a[[1]]
Just testing
> a[[a=1]]
Just testing
> a[[b=1]]
Just testing
...
> a[[v=1]]
Just testing
> a[[w=1]]
Just testing
> a[[x=1]]
Error in a[[x = 1]] : subscript out of bounds
> a[[y=1]]
Just testing
> a[[z=1]]
Just testing

Can someone explain me why the "[[x=1]]" case is treated differently?

Cheers,
H.




[Rd] More strange [[ behaviour
Herve Pages