Skip to content

When using {} in RHS of :=, sometimes NULL does not remove a column. #5284

@eutwt

Description

@eutwt

I installed from the GitHub master branch. I'm not understanding why the first result is not the same as the second.

library(data.table)

dd <- data.table(x = 1)
dd[, c('z', 'x') := {x <- NULL; list(2, NULL)}][]
#>        x     z
#>    <num> <num>
#> 1:     2     2
dd <- data.table(x = 1)
dd[, c('z', 'x') := {list(2, NULL)}][]
#>        z
#>    <num>
#> 1:     2
System Info
version
#>                _                           
#> platform       x86_64-apple-darwin17.0     
#> arch           x86_64                      
#> os             darwin17.0                  
#> system         x86_64, darwin17.0          
#> status                                     
#> major          4                           
#> minor          1.0                         
#> year           2021                        
#> month          05                          
#> day            18                          
#> svn rev        80317                       
#> language       R                           
#> version.string R version 4.1.0 (2021-05-18)
#> nickname       Camp Pontanezen

Created on 2021-12-11 by the reprex package (v2.0.1)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions