#are defers guarenteed to be executed in order?

1 messages · Page 1 of 1 (latest)

white fern
#

Freeing the contents of an Array depends on the array itself not having been freed yet. Is there any guarantee of the order in which defers are executed in?

var stringArr = Array(String).new(4);
defer stringArr.freeContents();
defer stringArr.free();
hollow bough
#

executed in reverse order, guaranteed™️

blazing quail
#

You could defer a block if you want

defer {
    stringArr.freeContents();
    stringArr.free();
}```
hollow bough
#

wait nvm you probably want freecontents before free