Style question for functions with in place transforms and return types

It is perfectly reasonable to return a value from an in-place function; most in-place functions in Julia return something useful.

You usually want to think about how your function f!(X) might be composed with other function in order to decide on the return value.

For example, many in-place functions return the altered collection, so that you can compose them with other functions that act on collections, e.g.

first(sort!(push!(A, x))) # returns first element of sorted [A; x]

In other cases, e.g. eigvals!(A), it is more useful to return some quantity computed from the altered collection. It sounds like that may be analogous to your situation.

1 Like