Permalink
Browse files

Fixes to Set, KeySet, Bag, and KeyBag stringification routines.

  • Loading branch information...
1 parent b1710c1 commit 2e98224d3c26fe90b93d97cb42e8bab7b10f527d @colomon colomon committed May 9, 2013
Showing with 12 additions and 12 deletions.
  1. +12 −12 lib/CORE.setting
View
@@ -2190,9 +2190,9 @@ class Set does Associative {
multi to-set (%elems --> Set) { Set.new: %elems.keys }
multi to-set ($elem --> Set) { die "Cannot coerce $elem.perl() to a Set; use set($elem.perl()) to create a one-element set" }
- submethod Str(Any:D $ : --> Str) { %!elems.keys().join(" ") }
- submethod gist(Any:D $ : --> Str) { "set({ %!elems.keys».gist.join(', ') })" }
- submethod perl(Any:D $ : --> Str) { 'set(' ~ join(', ', map { .perl }, %!elems.keys) ~ ')' }
+ method Str() { %!elems.keys().join(" ") }
+ method gist() { self.defined ?? "set({ %!elems.keys».gist.join(', ') })" !! "(Set)" }
+ method perl() { self.defined ?? 'set(' ~ join(', ', map { .perl }, %!elems.keys) ~ ')' !! "Set" }
method iterator() { %!elems.keys.iterator }
method list() { %!elems.keys }
@@ -2306,9 +2306,9 @@ class KeySet does Associative {
submethod BUILD (%!elems) { }
- submethod Str(Any:D $ : --> Str) { %!elems.keys().join(" ") }
- submethod gist(Any:D $ : --> Str) { "keyset({ %!elems.keys».gist.join(', ') })" }
- submethod perl(Any:D $ : --> Str) { 'KeySet.new(' ~ join(', ', map { .perl }, %!elems.keys) ~ ')' }
+ method Str() { %!elems.keys().join(" ") }
+ method gist() { self.defined ?? "keyset({ %!elems.keys».gist.join(', ') })" !! "(KeySet)" }
+ method perl() { self.defined ?? 'keyset(' ~ join(', ', map { .perl }, %!elems.keys) ~ ')' !! "KeySet" }
method iterator() { %!elems.keys.iterator }
method list() { %!elems.keys }
@@ -2352,9 +2352,9 @@ class Bag does Associative does Baggy {
submethod BUILD (%!elems) { }
- submethod Str(Any:D $ : --> Str) { %!elems.pairs.map({ $_.key xx $_.value }).flat.join(" ") }
- submethod gist(Any:D $ : --> Str) { "bag({ self.pairs>>.gist.join(', ') })" }
- submethod perl(Any:D $ : --> Str) { 'Bag.new(' ~ %!elems.perl ~ ')' }
+ method Str() { %!elems.pairs.map({ $_.key xx $_.value }).flat.join(" ") }
+ method gist() { self.defined ?? "bag({ self.pairs>>.gist.join(', ') })" !! "(Bag)" }
+ method perl() { self.defined ?? 'Bag.new(' ~ %!elems.perl ~ ')' !! "Bag" }
method iterator() { %!elems.pairs.iterator }
method list() { %!elems.keys }
@@ -2430,9 +2430,9 @@ class KeyBag does Associative does Baggy {
submethod BUILD (%!elems) { }
- submethod Str(Any:D $ : --> Str) { %!elems.pairs.map({ $_.key xx $_.value }).flat.join(" ") }
- submethod gist(Any:D $ : --> Str) { "keybag({ self.pairs>>.gist.join(', ') })" }
- submethod perl(Any:D $ : --> Str) { 'KeyBag.new(' ~ %!elems.perl ~ ')' }
+ method Str() { %!elems.pairs.map({ $_.key xx $_.value }).flat.join(" ") }
+ method gist() { self.defined ?? "keybag({ self.pairs>>.gist.join(', ') })" !! "(KeyBag)" }
+ method perl() { self.defined ?? 'KeyBag.new(' ~ %!elems.perl ~ ')' !! "KeyBag" }
method iterator() { %!elems.pairs.iterator }
method list() { %!elems.keys }

0 comments on commit 2e98224

Please sign in to comment.