On 2/6/19 5:19 AM, Brad Gilbert wrote:
     > The reason there is a Nil, is you asked for the ord of an empty
    string.
     >
     >      "".ord =:= Nil
     >
     > The reason there are two empty strings is you asked for them.

    What would be the most practice [practical] way of converting a string to 
and
    array of characters?

    $x="abc" goes to @y[0]="a", @y[1]="b", @y[2]="c"



On 2/6/19 12:12 PM, Laurent Rosenfeld via perl6-users wrote:
Brad told you already: use comb.


Le mer. 6 févr. 2019 à 20:57, ToddAndMargo via perl6-users <perl6-users@perl.org <mailto:perl6-users@perl.org>> a écrit :



Hi Laurent,

Pretty!  Thank you!

$ p6 'my Str $x="abcd"; for $x.comb.kv -> $i, $j {say "Index <$i> = <$j> = ord <" ~ ord($j) ~ ">";}'

Index <0> = <a> = ord <97>
Index <1> = <b> = ord <98>
Index <2> = <c> = ord <99>
Index <3> = <d> = ord <100>

Certainly very practical.  If dealing with large strings, is
it the most efficient?

-T

Reply via email to