develooper Front page | perl.perl6.users | Postings from February 2019

split and nils?

Thread Next
From:
ToddAndMargo via perl6-users
Date:
February 6, 2019 05:05
Subject:
split and nils?
Message ID:
bba1e965-7aa1-2cf5-db03-55374bf606d3@zoho.com
Hi All,

What is with the starting ending Nils?  There are only four
elements, why now six?

And how to I correct this?

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

Use of Nil in string context
   in block  at -e line 1
Index <0> = <> = ord <>         <----------------- nil ???
Index <1> = <a> = ord <97>
Index <2> = <b> = ord <98>
Index <3> = <c> = ord <99>
Index <4> = <d> = ord <100>
Use of Nil in string context
   in block  at -e line 1
Index <5> = <> = ord <>         <----------------- nil ???


Many thanks,
-T

Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About