Skip to content

Commit

Permalink
let chrs also work with numbers that are in Str form
Browse files Browse the repository at this point in the history
  • Loading branch information
timo committed Nov 11, 2016
1 parent dcfd4ed commit 4ae3f23
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions src/core/Str.pm
Expand Up @@ -2751,10 +2751,14 @@ sub chrs(*@c) returns Str:D {
my $value;
nqp::istype(($value := nqp::atpos($list,$i)),Int)
?? nqp::bindpos_s($result,$i,nqp::chr($value))
!! fail X::TypeCheck.new(
operation => "converting element #$i to .chr",
got => $value,
expected => Int)
!! nqp::istype($value, Str)
?? (nqp::istype(($value := +$value), Failure)
?? return $value
!! nqp::bindpos_s($result,$i,nqp::chr($value)))
!! fail X::TypeCheck.new(
operation => "converting element #$i to .chr",
got => $value,
expected => Int)
while nqp::islt_i(++$i,$elems);

nqp::join("",$result)
Expand Down

0 comments on commit 4ae3f23

Please sign in to comment.