develooper Front page | perl.perl6.users | Postings from April 2018

Blob - what am I missing?

Thread Next
From:
Fernando Santagata
Date:
April 17, 2018 08:50
Subject:
Blob - what am I missing?
Message ID:
CAJ+jyGjsHEdDttcAZHk=17az7RudTjxCB2jOUZ8awiq-PZCviQ@mail.gmail.com
Hi,
I'm experimenting with Blob(s) and I'm under the impression that I don't
understand how they work.

The documentation for the allocate() method (
https://docs.perl6.org/type/Blob#method_allocate) reads:

Returns a newly created Blob object with the given number of elements.
>

but when I try it in the REPL, I get strange results:

> my Blob $b0.allocate(10, 0)
Blob:0x<00 00 00 00 00 00 00 00 00 00>
> $b0.WHAT
(Blob)
> $b0.bytes
Invocant of method 'bytes' must be an object instance of type 'Blob', not a
type object of type 'Blob'.  Did you forget a '.new'?
  in block <unit> at <unknown file> line 1

> my Blob $b1 .= new;
Blob:0x<>
> $b1.WHAT
(Blob)
> $b1.bytes
0

Apparently allocate() doesn't return a "newly created Blob object," or am I
missing something?

(using 2018.03)

-- 
Fernando Santagata

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