Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
allow substr($str, $first, Inf)
  • Loading branch information
moritz committed Oct 14, 2012
1 parent 8230aef commit edb767a
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/core/Str.pm
Expand Up @@ -90,7 +90,9 @@ my class Str does Stringy {
).fail
if $istart > $ichars;
$length = $length($ichars - $istart) if nqp::istype($length, Callable);
my int $ilength = $length.defined ?? $length.Int !! $ichars - $istart;
my int $ilength = !$length.defined || $length === Inf
?? $ichars - $istart
!! $length.Int;
X::OutOfRange.new(
what => 'Length argument to substr',
got => $length,
Expand Down

0 comments on commit edb767a

Please sign in to comment.