Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Give Set/Bag/Mix single arg semantics, nine++
  • Loading branch information
lizmat committed Aug 28, 2015
1 parent 901d7c4 commit 0b76e79
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
8 changes: 7 additions & 1 deletion src/core/Baggy.pm
Expand Up @@ -18,7 +18,13 @@ my role Baggy does QuantHash {

method hash(Baggy:D: --> Hash) { %!elems.values.hash }

method new(*@args --> Baggy) {
multi method new(Baggy: \value) {
nqp::iscont(value) || nqp::not_i(nqp::istype(value, Iterable))
?? self!new([value])
!! self!new([|value])
}
multi method new(Baggy: **@args) { self!new(@args) }
method !new(@args) {
my %e;
# need explicit signature because of #119609
-> $_ { (%e{$_.WHICH} //= ($_ => 0)).value++ } for @args;
Expand Down
8 changes: 7 additions & 1 deletion src/core/Setty.pm
Expand Up @@ -20,7 +20,13 @@ my role Setty does QuantHash {
%e;
}

method new(*@args --> Setty) {
multi method new(Setty: \value) {
nqp::iscont(value) || nqp::not_i(nqp::istype(value, Iterable))
?? self!new([value])
!! self!new([|value])
}
multi method new(Setty: **@args) { self!new(@args) }
method !new(@args) {
my %e;
%e{$_.WHICH} = $_ for @args;
self.bless(:elems(%e))
Expand Down

0 comments on commit 0b76e79

Please sign in to comment.