Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Applying map_* on list of R6 objects #213

Closed
imanuelcostigan opened this issue Jul 2, 2016 · 1 comment

Comments

@imanuelcostigan
Copy link

commented Jul 2, 2016

Issue: map_* functions no longer works when calling an active binding of an R6 class.

Reprex:

Numbers <- R6::R6Class("Numbers",
  public = list(
    x = 100
  ),
  active = list(
    x2 = function(value) {
      if (missing(value)) return(self$x * 2)
      else self$x <- value/2
    },
    rand = function() rnorm(1)
  )
)

n1 <- Numbers$new()
n1[["x2"]]
# > [1] 200
n2 <- Numbers$new()
n2[["x2"]]
# > [1] 200
nn <- list(n1, n2)
purrr::map_dbl(nn, "x2")
# > Error: `x` must be a vector (not a environment)

Session:

> session_info()
Session info ------------------------------------------------------------------------------------
 setting  value                       
 version  R version 3.3.1 (2016-06-21)
 system   x86_64, darwin15.6.0        
 ui       RStudio (0.99.1246)         
 language (EN)                        
 collate  en_AU.UTF-8                 
 tz       Australia/Sydney            
 date     2016-07-03                  

Packages ----------------------------------------------------------------------------------------
 package   * version date       source        
 devtools  * 1.12.0  2016-06-24 CRAN (R 3.3.0)
 digest      0.6.9   2016-01-08 CRAN (R 3.3.0)
 magrittr    1.5     2014-11-22 CRAN (R 3.3.0)
 memoise     1.0.0   2016-01-29 CRAN (R 3.3.0)
 purrr       0.2.2   2016-06-18 CRAN (R 3.3.0)
 R6          2.1.2   2016-01-26 CRAN (R 3.3.0)
 Rcpp        0.12.5  2016-05-14 CRAN (R 3.3.0)
 rsconnect   0.4.3   2016-05-02 CRAN (R 3.3.0)
 withr       1.0.2   2016-06-20 CRAN (R 3.3.0)
@hadley

This comment has been minimized.

Copy link
Member

commented Mar 3, 2017

Related to #200: extract_impl() needs to be taught about environments

@hadley hadley closed this in 1fde13d Mar 4, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.