I might me missing something obvious here but I'm ...
# getting-started
j
I might me missing something obvious here but I'm trying to introduce nullable function parameter like
Copy code
fun <T : Any?> execute(queryId: (() -> UUID)? = null, operation: Operation<T>): T? {
but I can't invoke this by
Copy code
execute(Operation(...))
only
Copy code
execute(null, Operation(...))
works, any pointers?
d
You can only leave out trailing optional parameters, not leading ones. If you just want to pass the
operation
parameter you need to use named-parameters when calling:
Copy code
execute(operation=Operation(...))
👆 2
j
Ah, thats correct. Thanks.
m
so following this language rule you could move the lambda to be the last parameter, then you could call the function like this:
Copy code
execute(Operation(...))
or
Copy code
execute(Operation(...)) {
    // new uuid
}
👍 2