# StaticArray @buffer

**URL:** <https://forum.crystal-lang.org/t/staticarray-buffer/1680>\
**Category:** Help & Support\
**Created:** [February 7, 2020, 12:56am UTC](https://forum.crystal-lang.org/t/staticarray-buffer/1680 "2020-02-07T00:56:11Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![fhornung](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.crystal-lang.org/fhornung/32/705_2.png) [@fhornung](https://forum.crystal-lang.org/u/fhornung)\
**Post date:** [February 7, 2020, 12:56am UTC](https://forum.crystal-lang.org/t/staticarray-buffer/1680/1 "2020-02-07T00:56:11Z")

</div>

I checked StaticArray implementation. It is not clear to me what is @buffer and where is declared/initialized. There is only one appearance of @buffer in StaticArray code and it is in to\_unsafe method. How it works? :)

---

<div class="post-metadata">

**Author:** ![ComputerMage](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.crystal-lang.org/computermage/32/719_2.png) [@ComputerMage](https://forum.crystal-lang.org/u/ComputerMage)\
**Post date:** [February 7, 2020, 2:20am UTC](https://forum.crystal-lang.org/t/staticarray-buffer/1680/2 "2020-02-07T02:20:32Z")

</div>

`@buffer` is an instance variable.  
You don’t have to access it directly. you can call `StaticArray.to_unsafe` explicitly or it will be called by compiler implicitly when you will use it when calling C bindings.

---

<div class="post-metadata">

**Author:** ![fhornung](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.crystal-lang.org/fhornung/32/705_2.png) [@fhornung](https://forum.crystal-lang.org/u/fhornung)\
**Post date:** [February 7, 2020, 6:25am UTC](https://forum.crystal-lang.org/t/staticarray-buffer/1680/3 "2020-02-07T06:25:42Z")

</div>

It should be an instance variable but, it is not defined in StaticArray. So, it is not clear to me where is it defined.

---

<div class="post-metadata">

**Author:** ![bew](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.crystal-lang.org/bew/32/113_2.png) [@bew](https://forum.crystal-lang.org/u/bew)\
**Post date:** [February 7, 2020, 8:43am UTC](https://forum.crystal-lang.org/t/staticarray-buffer/1680/4 "2020-02-07T08:43:23Z")

</div>

It is defined in the compiler. StaticArray is a special type that is managed by the compiler at the end of the day, and its fields are defined there as well

Here to be exact: [https://github.com/crystal-lang/crystal/blob/5905aa504cab7cff391b5875f88d30eef978c3fb/src/compiler/crystal/program.cr#L192](https://github.com/crystal-lang/crystal/blob/5905aa504cab7cff391b5875f88d30eef978c3fb/src/compiler/crystal/program.cr#L192)

---

<div class="post-metadata">

**Author:** ![fhornung](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.crystal-lang.org/fhornung/32/705_2.png) [@fhornung](https://forum.crystal-lang.org/u/fhornung)\
**Post date:** [February 7, 2020, 9:08am UTC](https://forum.crystal-lang.org/t/staticarray-buffer/1680/5 "2020-02-07T09:08:16Z")

</div>

Thx for info!
