# Array : cannot implicitly instantiate

**URL:** <https://forum.dfinity.org/t/array-cannot-implicitly-instantiate/9123>\
**Category:** Language Support\
**Tags:** Motoko\
**Created:** [November 27, 2021, 10:03am UTC](https://forum.dfinity.org/t/array-cannot-implicitly-instantiate/9123 "2021-11-27T10:03:01Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![C-B-Elite](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/c-b-elite/32/34356_2.png) [@C-B-Elite](https://forum.dfinity.org/u/C-B-Elite)\
**Post date:** [November 27, 2021, 10:03am UTC](https://forum.dfinity.org/t/array-cannot-implicitly-instantiate/9123/1 "2021-11-27T10:03:01Z")

</div>

the code is :

```auto
var buffer : [var (Nat, Nat)] = [var];
buffer := Array.append(buffer, [var (1,1)]);

```

and I meet the error:

```auto
type error [M0098], cannot implicitly instantiate function of type
  <A>([A], [A]) -> [A]
to argument of type
  ([var (Nat, Nat)], [var (Nat, Nat)])
to produce result of type
  [var (Nat, Nat)]
because no instantiation of A/73 makes
  ([var (Nat, Nat)], [var (Nat, Nat)]) <: ([A/73], [A/73])
and
  [A/73] <: [var (Nat, Nat)]

```

I have known that the error can be handled by add the `<T>` after the `Array.append` function if the array is a immutable array, but here `buffer` is a mutable array

---

<div class="post-metadata">

**Author:** ![nomeata](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/nomeata/32/733_2.png) [@nomeata](https://forum.dfinity.org/u/nomeata)\
**Post date:** [November 27, 2021, 10:10am UTC](https://forum.dfinity.org/t/array-cannot-implicitly-instantiate/9123/2 "2021-11-27T10:10:40Z")

</div>

`Array.append` only works on immutable arrays (the ones without `var`), and mutable arrays (the ones with `var`) are a completely separate type. You could implement your own `append_var` function, but really, when you are appending arrays, you are probably using the wrong type. Have a look at the buffer type in the base library!

---

<div class="post-metadata">

**Author:** ![Ori](https://avatars.discourse-cdn.com/v4/letter/o/ecae2f/32.png) [@Ori](https://forum.dfinity.org/u/Ori)\
**Post date:** [November 27, 2021, 12:15pm UTC](https://forum.dfinity.org/t/array-cannot-implicitly-instantiate/9123/3 "2021-11-27T12:15:55Z")

</div>

Some reference for the buffer module in the base library for you: [motoko-base/Buffer.mo at master · dfinity/motoko-base · GitHub](https://github.com/dfinity/motoko-base/blob/master/src/Buffer.mo)

---

<div class="post-metadata">

**Author:** ![C-B-Elite](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/c-b-elite/32/34356_2.png) [@C-B-Elite](https://forum.dfinity.org/u/C-B-Elite)\
**Post date:** [November 28, 2021, 3:37pm UTC](https://forum.dfinity.org/t/array-cannot-implicitly-instantiate/9123/4 "2021-11-28T15:37:13Z")

</div>

Thank you, here `buffer` is not the real ‘Buffer’ but a temp array. I have realized the append function for [var T], thank you nomeata 🙂
