Created
January 7, 2016 15:38
-
-
Save meowcat/c51a4260fb710e2fa51a to your computer and use it in GitHub Desktop.
Copy constructors while using the class Versioned of Biobase: bug
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(Biobase) | |
setClass("A", | |
representation = representation(var1="integer"), | |
prototype=prototype(var1=integer(), | |
new("Versioned", versions=c(A = "0.1.0"))), | |
contains="Versioned") | |
ia <- new("A") | |
try(ia2 <- new("A", ia)) | |
# "ia" is mapped to the argument "versions" of the Versioned "initialize" method! | |
setMethod("initialize", "Versioned", function (.Object, ...) | |
{ | |
.local <- function (.Object, ..., versions = list()) | |
{ | |
.Object <- callNextMethod(.Object, ...) | |
classVersion(.Object)[names(versions)] <- versions | |
.Object | |
} | |
.local(.Object, ...) | |
} | |
) | |
setClass("A", | |
representation = representation(var1="integer"), | |
prototype=prototype(var1=integer(), | |
new("Versioned", versions=c(A = "0.1.0"))), | |
contains="Versioned") | |
ia <- new("A") | |
ia2 <- new("A", ia) | |
# works correctly |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment