StaticArray @buffer

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? :)

@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.

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

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:

1 Like

Thx for info!