Skip to content
Prev 22206 / 63421 Next

Strange behaviour of the [[ operator

Herve> Hi,
    Herve> This looks like a bug:
hmm, maybe...
or maybe not; I vaguely recall that this is documented somewhere...

    >> a <- list(b=5)
    >> a[['b']]
    Herve> [1] 5
    >> a[[t<-'b']]

    Herve> Nothing gets printed!

Yes, but that is not really much related to "[[" 
but rather to  "<-"  which momentarily turns off auto-printing.

Similar things happen in many similar circumstances.

    Herve> I need to use parenthesis to see the expected result:

    >> a[[(t<-'b')]]
    Herve> [1] 5

    Herve> Cheers,
    Herve> H.

Martin