Permalink
Browse files

Kill non-standard .set and .bag methods, update Bag.new-from-pairs so…

… that it doesn't issue warnings.
  • Loading branch information...
1 parent eaf57ce commit b15a1625d9d996c95b6c1a53c84507561a9b86e3 @colomon colomon committed Jun 9, 2013
Showing with 2 additions and 5 deletions.
  1. +2 −5 lib/CORE.setting
View
@@ -747,8 +747,6 @@ my class Cool {
Niecza-trans(self, @changes);
}
- method set() { set self }
- method bag() { bag self }
method Set() {
my @keys;
for self.list() {
@@ -1967,8 +1965,6 @@ my class Hash does Associative {
method pairs() { Q:CgOp { (hash_pairs {self}) } }
method list() { Q:CgOp { (hash_pairs {self}) } }
method kv() { Q:CgOp { (hash_kv {self}) } }
- method set() { set self }
- method bag() { bag self }
method Set() { self.list.Set }
method KeySet() { self.list.KeySet }
method Bag() { self.list.Bag }
@@ -2387,7 +2383,8 @@ class Bag does Associative does Baggy {
method new-from-pairs(@pairs --> Bag) {
my %e;
for @pairs {
- $_ ~~ Pair ?? %e{.key} += .value !! %e{$_}++;
+ when Pair { %e{.key} = .value + (%e{.key} // 0); }
+ %e{$_}++;
}
for %e -> $p {
die "Negative values are not allowed in Bags" if $p.value < 0;

0 comments on commit b15a162

Please sign in to comment.