Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Branch: sized-arrays
Fetching contributors…

Cannot retrieve contributors at this time

34 lines (29 sloc) 1.018 kB
my class Set does Setty {
has Int $!total;
has $!WHICH;
method total { $!total //= %!elems.elems }
submethod WHICH { $!WHICH }
submethod BUILD (:%elems) {
my @keys := %elems.keys.sort;
$!WHICH := self.^name ~ '|' ~ @keys.sort;
nqp::bindattr(self, Set, '%!elems', %elems);
}
method at_key($k --> Bool) {
so %!elems.exists_key($k.WHICH);
}
method delete ($a --> Bool) { # is DEPRECATED doesn't work in settings
DEPRECATED("the :delete adverb");
self.delete_key($a);
}
method delete_key($k --> Bool) is hidden_from_backtrace {
X::Immutable.new( method => 'delete_key', typename => self.^name ).throw;
}
method grab ($count = 1) {
X::Immutable.new( method => 'grab', typename => self.^name ).throw;
}
method grabpairs ($count = 1) {
X::Immutable.new( method => 'grabpairs', typename => self.^name ).throw;
}
method Set { self }
method SetHash { SetHash.new(self.keys) }
}
Jump to Line
Something went wrong with that request. Please try again.