toArray is deprecated: Use static library function instead

Hi teams,
I just upgraded to dfx 12.1 and I am now getting a bunch of Buffer-realted deprecation warning (eg. toArray()).
I used to manipulate data with Array, but then .append() got deprecated, with suggestion to use Buffer instead.
So then I was still using stable Arrays for storing while manipulating data with Buffer.
Now conversion back to Array won’t be possible in the future (Buffer.toArray being deprecarted).

Can anyone assist me in understanding what the patterns I should follow here :slight_smile: ?
What data type should I use for small lists of entries very frequently queried that are somewhat frequently updated?

Thanks

This is telling you to use:

Buffer.toArray(your_buffer);

Instead of

your_buffer.toArray();

It seems like the Buffer module has had significant updates. motoko-base/Buffer.mo at master · dfinity/motoko-base · GitHub

Oh boy, that was so simple… thanks amigo!

1 Like

I think my mistake comes from the fact that the VS code extension for motoko does not seem to be up to date with latest motoko versions

2 Likes

Amazing :heart:
Thank you :slight_smile:

1 Like

@rvanasa do you think we could add a motoko:version config to the vscode extension, or infer it from project config files?

As a quick update here, this is fixed in the past several versions of the VS Code extension.

@kpeacock Yep—we could use dfx.json to infer the compiler version.

1 Like