emmanuelparadis / ape

Analysis of Phylogenetics and Evolution
https://emmanuelparadis.github.io/
GNU General Public License v2.0
53 stars 11 forks source link

[<-.multiPhylo does not support empty [] #35

Closed ms609 closed 3 years ago

ms609 commented 3 years ago

The syntax myList[] <- X typically allows entries of a list to be modified without overwriting attributes.

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
ms609 commented 3 years ago

Accidental duplicate of #36, sorry!