Immutable version of Belt.Array.set?

The Belt.Array.set function modifies the original array in place.

But I need an immutable version that returns a new array without modifying the older one.

Is there an immutable set function in Belt API?

I know it is easy to implement one, but I wonder why Belt only has inplace version of set function.

I usually use Belt.Array.concat.

Depending on your use case, you could think about using a list.

Meanwhile in the rescript-core, there is ES2023 binding for immutable array set.

1 Like