#Unable to do a mutable pointer capture on the result of array.popOrNull()
1 messages · Page 1 of 1 (latest)
https://ziglang.org/documentation/master/std/#A;std:ArrayList.popOrNull
popOrNull removes the last element, it doesnt make sense to mutate the result
no
you're capturing a pointer to a temporary value
the last value is copied from the array
the length is decremented
and then the value is returned, copied
with the index it once occupied now being out of bounds
its a temporary value
it gets destroyed after its used, if you want to mutate it you need to assign it to a variable
aye, temporaries are always constant values
both allow the same thing, this not working is just because popOrNull returns a temporary