Skip to content

Instantly share code, notes, and snippets.

@meowcat
Created January 7, 2016 15:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save meowcat/c51a4260fb710e2fa51a to your computer and use it in GitHub Desktop.
Save meowcat/c51a4260fb710e2fa51a to your computer and use it in GitHub Desktop.
Copy constructors while using the class Versioned of Biobase: bug
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