Does Swift guarantee parameter evaluation order in an initializer? For example:
struct Foo {
let bar: String
let baz: Int
}
let test = Foo(bar: doSomethingAndReturnString(), baz: doSomethingAndReturnInt())
Will doSomethingAndReturnString()always be called before doSomethingAndReturnInt(), or could compiler optimizations change evaluation order? And, either way, is this behavior documented anywhere?
Thanks for the link! However, this seems to be a post more about functions called within functions, rather than functions called as arguments to parameters.
I was aware of this reply here:
but the "in most situations" makes me wonder if the parameters example I gave is included. Additionally, it is an older post, so I'm not sure how accurate the answer is to Swift today.