Accessing only a subset of function outputs

Since Julia 1.7 you can use property destruction (JuliaLang/julia#39285) as follows:

julia> foo() = (x1 =1, x2 = 2, x3 = 3);

julia> (; x2) = foo();

julia> x2
2

If your functions return too many things such that this is a problem I would rething the API and maybe break things down into smaller pieces.

This is already possible (unless going from 1 to more return values), for example:

julia> foo() = (1, 2, 3);

julia> _, b = foo();

julia> b
2
4 Likes