[Rcpp-devel] Odd-seeming behaviour of [[ and $

North, Ben Ben.North at sig.com
Mon Oct 22 11:17:36 CEST 2012


Hi Romain,

Thanks for the reply.

> > The fact that 'x[["value"]]' finds the method only if I've first done
> > 'x$value' seemed odd.
>
> This is an implementation artefact. In short, you are not supposed to
> use [[.

OK, fair enough :)

Because `$` doesn't evaluate its field-name argument, is

    field.name <- "value"
    do.call(`$`, list(x, field.name))

the recommended way of accessing methods whose names are computed at
run-time?  It does work; just wondering if there's a better way.

Thanks,

Ben.


________________________________

Susquehanna International Group Limited

Susquehanna International Group Limited is a private company limited by shares and registered in Ireland. Registration No.: 445356. Registered Address: 4th Floor, Georges Dock House, IFSC, Dublin 1, Ireland.
Susquehanna Ireland Limited is a private company limited by shares and registered in Ireland. Registration No.: 305632. Registered Address: 4th Floor, Georges Dock House, IFSC, Dublin 1, Ireland.
Susquehanna International Securities Limited is a private company limited by shares and registered in Ireland. Registration No.: 337946. Registered Address: 4th Floor, Georges Dock House, IFSC, Dublin 1, Ireland.

IMPORTANT: The information contained in this email and/or its attachments is confidential. If you are not the intended recipient, please notify the sender immediately by reply and immediately delete this message and all its attachments. Any review, use, reproduction, disclosure or dissemination of this message or any attachment by an unintended recipient is strictly prohibited. Neither this message nor any attachment is intended as or should be construed as an offer, solicitation or recommendation to buy or sell any security or other financial instrument. Neither the sender, his or her employer nor any of their respective affiliates makes any warranties as to the completeness or accuracy of any of the information contained herein or that this message or any of its attachments is free of viruses.


More information about the Rcpp-devel mailing list