Believe it or not, but many of the array class methods convert the array to a Buffer
, and then back to an Array
.
See the Array.filter
implementation in motoko-base - I would recommend just copying the Buffer
filter logic/functionality from there. You can expand upon that to do the same for .find()
.
Buffer has .get()
methods for retrieving indexes as well, so I would honestly only use an Array
if you’re sure that your index-able list isn’t going to change in size - otherwise, Buffer
all the way.