# How to pattern match mutable fields inside object?

**URL:** <https://forum.dfinity.org/t/how-to-pattern-match-mutable-fields-inside-object/16177>\
**Category:** Language Support\
**Created:** [October 26, 2022, 4:34pm UTC](https://forum.dfinity.org/t/how-to-pattern-match-mutable-fields-inside-object/16177 "2022-10-26T16:34:31Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![cryptoschindler](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/cryptoschindler/32/26_2.png) [@cryptoschindler](https://forum.dfinity.org/u/cryptoschindler)\
**Post date:** [October 26, 2022, 4:34pm UTC](https://forum.dfinity.org/t/how-to-pattern-match-mutable-fields-inside-object/16177/1 "2022-10-26T16:34:32Z")

</div>

How can I pattern match the mutable fields of an object in Motoko like the commented out lines in the following REPL?

> **[Motoko Playground - DFINITY](https://m7sm4-2iaaa-aaaab-qabra-cai.raw.ic0.app/?tag=513555761)**
>
> A playground for the Internet Computer's native Motoko language, brought to you by DFINITY

@claudio

---

<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:** [October 26, 2022, 6:41pm UTC](https://forum.dfinity.org/t/how-to-pattern-match-mutable-fields-inside-object/16177/2 "2022-10-26T18:41:35Z")

</div>

The short answer is that you can’t at the moment.

One could allow this but then there is the question of whether you just want to bind the location, allow pattern matching on the current value in that location, or both.

We also don’t have array patterns at the moment, which present similar issues.

---

<div class="post-metadata">

**Author:** ![cryptoschindler](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/cryptoschindler/32/26_2.png) [@cryptoschindler](https://forum.dfinity.org/u/cryptoschindler)\
**Post date:** [October 27, 2022, 7:15am UTC](https://forum.dfinity.org/t/how-to-pattern-match-mutable-fields-inside-object/16177/3 "2022-10-27T07:15:46Z")

</div>

> [@claudio](#):
>
> just want to bind the location, allow pattern matching on the current value in that location, or both.

I can’t really follow what that means 😃 do you maybe have an example? Why does this ambiguity not appear for immutable types?
