What's the differences between `throw(ArgumentError(""))` and `return throw(ArgumentError("")`)

Here the return keyword is useless and misleading. The following:

function f()
    return throw(...)
end

is a bit like

function f()
    return sin("abc")   # Some invalid code that throws an error
end

In both cases, Julia is supposed to evaluate an expression and return the result. But in both cases, an exception is thrown during evaluation, so the execution is stopped before the function returns anything.

4 Likes