RosettaCodeData/Task/Singleton/Lasso/singleton-2.lasso
2016-12-05 23:44:36 +01:00

16 lines
272 B
Text

// Define thread level singleton
define singleton => type {
data public switch = 'x'
public oncreate => var(.type)->isa(.type) ? var(.type) | var(.type) := self
}
local(
a = singleton,
b = singleton,
)
#a->switch = 'a'
#b->switch = 'b'
#a->switch // b