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

Question about Blob and Buf

Thread Next
From:
David Santiago
Date:
February 11, 2020 09:56
Subject:
Question about Blob and Buf
Message ID:
BF5A91C2-9094-411D-8E07-1759DD20AC6F@gmail.com
A 11 de fevereiro de 2020 10:47:34 CET, David Santiago <demanuel@gmail.com> escreveu:
>A 11 de fevereiro de 2020 09:46:06 CET, David Santiago <demanuel@gmail.com> escreveu:
>>
>>Hi!
>>
>>Can someone explain me why this doesn't work:
>>
>>my Blob $read;
>>$read ~= $socket.read(1024);
>>
>>Dies with error:
>>
>>X::Buf::AsStr: Cannot use a Buf as a string, but you called the Stringy method on it
>>
>>This also doesn't work:
>>
>>my Buf $read;
>>$read ~= $socket.read(1024);
>>
>>Dies with the same error as above.
>>
>>
>>But this works?
>>
>>my Blob $read = Buf.new;
>>$read ~= $socket.read(1024);
>>
>>
>>Best regards,
>>David Santiago
>
>
>Hi!
>
>Can someone explain me why this doesn't work:
>
>my Blob $read;
>$read ~= $socket.read(1024);
>
>Dies with error:
>
>X::Buf::AsStr: Cannot use a Buf as a string, but you called the Stringy method on it
>
>This also doesn't work:
>
>my Buf $read;
>$read ~= $socket.read(1024);
>
>Dies with the same error as above.
>
>
>But this works?
>
>my Blob $read = Buf.new;
>$read ~= $socket.read(1024);
>
>
>Best regards,
>David Santiago


Hi!

Can someone explain me why this doesn't work:

my Blob $read;
$read ~= $socket.read(1024);

Dies with error:

X::Buf::AsStr: Cannot use a Buf as a string, but you called the Stringy method on it

This also doesn't work:

my Buf $read;
$read ~= $socket.read(1024);

Dies with the same error as above.


But this works?

my Blob $read = Buf.new;
$read ~= $socket.read(1024);


Best regards,
David Santiago

-- 
Sent from my Android device with K-9 Mail. Please excuse my brevity.

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