Hex.mo:48.17-48.30: warning [M0154], field unwrap is deprecated:
Option.unwrap is unsafe and fails if the argument is null; it will be removed soon; use a switch or do? expression instead
Hex.mo:51.27-51.39: warning [M0154], field append is deprecated:
Array.append has critical performance flaws; use a Buffer, and Buffer.append, instead.
Is there any sample for the how we can use do? instead of Option.unwrap and Buffer.append instead of Array.append
For the first question on handling options, please have a look at the reference here: Untitled :: Internet Computer
There’s an explanation of handling options witch switch/case and below is an explanation of option blocks do ? { }.
Concerning Array.append and Buffer.append, an example to work with Buffers generated from Arrays would be the following. However, it would be good if someone with more Motoko experience could comment
let array1 = [1,2];
let array2 = [3,4];
let buffer1 = Buffer.Buffer<Nat>(array1.size());
for (entry in array1.vals()) {
buffer1.add(entry)
};
let buffer2 = Buffer.Buffer<Nat>(array2.size());
for (entry in array2.vals()) {
buffer2.add(entry)
};
buffer1.append(buffer2);