Skip to content

Internally accessing ref class methods with .self$x is different from .self[['x']]

3 messages · Gabriel Becker, Winston Chang

#
On Wed, Oct 16, 2013 at 3:41 PM, Gabriel Becker <gmbecker at ucdavis.edu> wrote:
I wasn't able to get .self$usingMethods() to work either. I think that
for my case, it still won't do the job - the issue is that I'm calling
a method and passing the name of another method, which is accessed via
[[. Since .self$usingMethods() supposedly analyzes code when the class
is installed (and not at runtime), that wouldn't help in this case.

Previously I said that code like this would work, but I was wrong:
  var <- "someMethod"
  `$`(.self, var)
It doesn't work because $ doesn't evaluate var; it thinks you're
trying to get .self$var, not .self$someMethod.

The workaround we're using for now is:
  do.call(`$`, list(.self, var))

-Winston