Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Unify on returning Nil on non-existing elements
  • Loading branch information
lizmat committed Jan 15, 2015
1 parent a0de41f commit bba2447
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/core/Capture.pm
Expand Up @@ -32,23 +32,23 @@ my class Capture { # declared in BOOTSTRAP

multi method at_key(Capture:D: \key) {
my str $skey = nqp::unbox_s(key.Str);
nqp::existskey($!hash,$skey) ?? nqp::atkey($!hash, $skey) !! Any;
nqp::existskey($!hash,$skey) ?? nqp::atkey($!hash, $skey) !! Nil;
}
multi method at_key(Capture:D: Str:D \key) {
my str $skey = nqp::unbox_s(key);
nqp::existskey($!hash,$skey) ?? nqp::atkey($!hash, $skey) !! Any;
nqp::existskey($!hash,$skey) ?? nqp::atkey($!hash, $skey) !! Nil;
}

multi method at_pos(Capture:D: int \pos) {
X::OutOfRange.new(:what<Index>,:got(pos),:range<0..Inf>).throw
if nqp::islt_i(pos,0);
nqp::existspos($!list,pos) ?? nqp::atpos($!list,pos) !! Any;
nqp::existspos($!list,pos) ?? nqp::atpos($!list,pos) !! Nil;
}
multi method at_pos(Capture:D: Int:D \pos) {
my int $pos = nqp::unbox_i(pos);
X::OutOfRange.new(:what<Index>,:got(pos),:range<0..Inf>).throw
if nqp::islt_i($pos,0);
nqp::existspos($!list,$pos) ?? nqp::atpos($!list,$pos) !! Any;
nqp::existspos($!list,$pos) ?? nqp::atpos($!list,$pos) !! Nil;
}

method hash(Capture:D:) {
Expand Down

0 comments on commit bba2447

Please sign in to comment.