Skip to content

Commit

Permalink
Give QuantHash/Capture a proper .item method
Browse files Browse the repository at this point in the history
Fixes #1862.  Kudos to Ralph Mellor for mentioning this.

Following jnthn's comment then:

    If  something decides that it's going to implement .iterator
    without making itself Iterable, then it's on that type to also
    implement method item,  I'd say
  • Loading branch information
lizmat committed Jan 28, 2021
1 parent 3865f1c commit 8f6c7fe
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/core.c/Capture.pm6
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ my class Capture { # declared in BOOTSTRAP
# has %!hash; # named parameters

method from-args(|c) { c }
method item() is raw { my $ = self }

submethod BUILD(:@list, :%hash --> Nil) {
my Int:D $elems = @list.elems; # force reification of all
Expand Down
1 change: 1 addition & 0 deletions src/core.c/QuantHash.pm6
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
my role QuantHash does Associative {

method keyof() { Mu }
method item() is raw { my $ = self }

method SET-SELF(QuantHash:D: \elems) is implementation-detail {
nqp::bindattr(self,::?CLASS,'$!elems',elems)
Expand Down

0 comments on commit 8f6c7fe

Please sign in to comment.