Hello 

When I create a new instance of an S4 class in R, I would like the newly
created object to have a unique id field. I try to achieve it through
UUIDgenerate() from the uuid package. The problem is that I obtain the
same UUID at every new object instance : 

library(uuid)
setClass("C",
 representation=representation(
 id = "character"
 ),
 prototype = prototype(
 id = UUIDgenerate(use.time = TRUE))
 )

 new("C")

An object of class "C" Slot "id": [1]
"1e07d7c2-2d71-11e6-b5e1-e1f59d8ccf09" 

new("C")

An object of class "C" Slot "id": [1]
"1e07d7c2-2d71-11e6-b5e1-e1f59d8ccf09" 

new("C")

An object of class "C" Slot "id": [1]
"1e07d7c2-2d71-11e6-b5e1-e1f59d8ccf09" 

Calling UUIDgenerate() successively at the R command line produces
different UUIDS each time. 

Where do I go wrong? 

Thanks 

Servet 

 
        [[alternative HTML version deleted]]

______________________________________________
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to