Skip to content
Back to formatted view

Raw Message

Message-ID: <452166BB.3040901@fhcrc.org>
Date: 2006-10-02T19:21:31Z
From: Hervé Pagès
Subject: More strange [[ behaviour

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.