What is the best way to update an array element in FQL?
For example, incrementing the below array’s value at zero-based index 2 from 3 to 4
Let(
{
array: [1, 2, 3, 4, 5],
},
# ???
)
# should result in [1, 2, 4, 4, 5]
I see that I can use Select to get an array value at a specific index, but couldn’t find any equivalent function for setting values at a specific index.
I also considered using a Foreach or Map to iterate the array, but I don’t see any documentation indicating the associated Lambda can access the current iteration’s array index.
Apologies if this has already been asked before or is covered in the docs. I searched, but may have missed something.
So my brain turned on and realized I could use Reduce for this.
Would still be interested in hearing if there’s a more direct way to update an array element at a given index, but for now this approach is working for me.