@array does role {
method insert ($x) {
@.push($x) unless any(self) eqv $x;
}
}
####
pugs> my @array does role {
....> method insert ($x) { @.push($x) if none(self) eqv $x }
....> }
()
pugs> my @array=(1..5);
pugs> @array.insert($_) for 1,2,6;
pugs> say @array
123456
Bool::True
####
pugs> my @array does role {
....> method insert ($x) { @.push($x) if none(self) eqv $x }
....> } = (1..5);
(1, 2, 3, 4, 5)
####
pugs> my @array does role {
....> multi method insert ($x) { @.push($x) if none(self) eqv $x }
....> multi method insert (@x) { @.insert($_) for @x }
....> } = 1..5;
(1, 2, 3, 4, 5)
pugs> @array.insert(3..7);
pugs> say @array
1234534567
Bool::True
####
pugs> self
macro {Prim ([Pugs.AST.Internals.Val] -> Pugs.AST.Eval.Eval Pugs.AST.Internals.Val)}