On 6/18/22 21:13, ToddAndMargo via perl6-users wrote:
Hi All,

What am I doing wrong here:

 > my Buf $y = Buf.new( 0xFA xx 10);
Buf:0x<FA FA FA FA FA FA FA FA FA FA>

 > $y ~= 0xBB.encode.Buf;
Buf:0x<FA FA FA FA FA FA FA FA FA FA 31 38 37>

I got three entries (31 38 37) instead of one (0xBB)


Some more goofing around:

 > $y ~= 0xBB;
Stringification of a Buf is not done with 'Str'.  The 'decode' method
should be used to convert a Buf to a Str.
   in block <unit> at <unknown file> line 1

[10] > $y += 0xBB;
Type check failed in assignment to $y; expected Buf but got Int (201)
   in block <unit> at <unknown file> line 1



Many thanks,
-T

Figured it out.  Use `append`:

   > $x
   Buf:0x<41 42 43 44>

   > $x.append( 0xDD );
   Buf:0x<41 42 43 44 DD>

   > $x.append( 0xEE..0xF1 );
   Buf:0x<41 42 43 44 DD EE EF F0 F1>

   > $x.append( 0xA1, 0xA3, 0xA5 );
   Buf:0x<41 42 43 44 DD EE EF F0 F1 A1 A3 A5>

Reply via email to