# How to append to an Array that is a default Value of a Hash?

**URL:** <https://forum.crystal-lang.org/t/how-to-append-to-an-array-that-is-a-default-value-of-a-hash/2144>\
**Category:** Help & Support\
**Created:** [May 21, 2020, 2:58pm UTC](https://forum.crystal-lang.org/t/how-to-append-to-an-array-that-is-a-default-value-of-a-hash/2144 "2020-05-21T14:58:38Z")\
**Posts on this page:** 1\
**Showing post:** 5

<div class="post-metadata">

**Author:** ![bcardiff](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.crystal-lang.org/bcardiff/32/3_2.png) [@bcardiff](https://forum.crystal-lang.org/u/bcardiff)\
**Post date:** [May 21, 2020, 3:22pm UTC](https://forum.crystal-lang.org/t/how-to-append-to-an-array-that-is-a-default-value-of-a-hash/2144/5 "2020-05-21T15:22:07Z")

</div>

Beware of the defualt\_value semantics. You will end up with a shared array.

`Hash.new` can a block to lazy initialize entries. That might be more helpful.

Also, relevant old issue: [https://github.com/crystal-lang/crystal/issues/4376](https://github.com/crystal-lang/crystal/issues/4376)

---

_[View the full topic](https://forum.crystal-lang.org/t/how-to-append-to-an-array-that-is-a-default-value-of-a-hash/2144)._
