# How to remove item in mutable array?

**URL:** <https://forum.dfinity.org/t/how-to-remove-item-in-mutable-array/2699>\
**Category:** Developers\
**Created:** [May 5, 2021, 8:20am UTC](https://forum.dfinity.org/t/how-to-remove-item-in-mutable-array/2699 "2021-05-05T08:20:43Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![flyq](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/flyq/32/3637_2.png) [@flyq](https://forum.dfinity.org/u/flyq)\
**Post date:** [May 5, 2021, 8:20am UTC](https://forum.dfinity.org/t/how-to-remove-item-in-mutable-array/2699/1 "2021-05-05T08:20:43Z")

</div>

I want remove some items in a mutable array, But I don’t find the `remove` or some functions in [Array base library](https://github.com/dfinity/motoko-base/blob/master/src/Array.mo).

And I find some [examples](https://github.com/dfinity/examples/blob/master/motoko/simple-to-do/src/Utils.mo#L46-L55):

```auto
  // Clear to-do item utility
  public func clear(todos: [ToDo]) : [ToDo] {
    var updated : [ToDo] = [];
    for (todo : ToDo in todos.vals()) {
      if (not todo.completed) {
        updated := Array.append<ToDo>(updated, [todo]);
      };
    };
    updated
  };

```

This is by creating a new array and copying all the elements except to the be deleted one into the new array. is this will result in poor performance for relatively large arrays?

---

<div class="post-metadata">

**Author:** ![claudio](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/claudio/32/322_2.png) [@claudio](https://forum.dfinity.org/u/claudio)\
**Post date:** [May 5, 2021, 10:07am UTC](https://forum.dfinity.org/t/how-to-remove-item-in-mutable-array/2699/2 "2021-05-05T10:07:09Z")

</div>

Arrays in Motoko are fixed size as in languages like Java and C# (and unlike Javascript).

If you want to support deletion without full copying, it might be better to choose a different data structure like `List` (a single-linked list) (see `List.filter`) or something more fancy like `TrieSet`.

Even the `Array.append` method will copy contents into a new array and should therefore be avoided when worried about efficiency (e.g. in inner loops).

Hope that helps!

We should probably rework some of the examples but they were always written for simplicity of presentation, not necessarily efficiency.
