Closed ms609 closed 3 years ago
The syntax myList[] <- X typically allows entries of a list to be modified without overwriting attributes.
myList[] <- X
Compare:
myList <- structure(1:5, class = 'myClass') class(myList) # "myClass" myList[] <- sapply(myList, `*`, 2) class(myList) # attributes retained myList <- lapply(myList, `*`, 2) class(myList) # attributes lost
Accidental duplicate of #36, sorry!
The syntax
myList[] <- X
typically allows entries of a list to be modified without overwriting attributes.Compare: