Multiton: Difference between revisions

Content added Content deleted
m (→‎{{header|Raku}}: simplify)
m (→‎{{header|Raku}}: simplify)
Line 133: Line 133:
class Multiton {
class Multiton {


my %instances = MultitonType.keys Z=> $ ⚛= 1 xx MultitonType.keys.elems;
my %instances = MultitonType.keys Z=> $ ⚛= 1 xx * ;


has $.type is rw;
has $.type is rw;


method TWEAK { self.type = 'Nothing' unless cas(%instances{self.type}, 1, 0) }
method TWEAK { $.type = 'Nothing' unless cas(%instances{$.type}, 1, 0) }
}
}