$ p6 'my $fh=open "/home/linuxutil/To", :r; my Buf $f = $fh.read( 10 ); $fh.close; dd $f; for $f[0..*] -> $Byte { if $Byte == 0b00 {say "Binary"; last;}else{say $Byte}}'

Buf[uint8] $f = Buf[uint8].new(87,111,114,100,80,114,111,0,0,0)

87
111
114
100
80
114
111
Binary

To get the above to work, I had to say `$f[0..*]`. If I used
`$f`, it made one loop over the entire variable.

$ p6 'my $fh=open "/home/linuxutil/To", :r; my Buf $f = $fh.read( 10 ); $fh.close; dd $f; for $f -> $Byte { if $Byte == 0b00 {say "Binary"; last;}else{say $Byte}}'

Buf[uint8] $f = Buf[uint8].new(87,111,114,100,80,114,111,0,0,0)
Buf[uint8]:0x<57 6f 72 64 50 72 6f 00 00 00>


I never have to say `$str[0..*]` when looping over a string.  Why?

Yours in confusion,
-T

Reply via email to