i wrote a function that will throw an ArgumentError if it occurred any exception.
but i have a question about throwing an error:
i can use
throw() directly, also i can use the
Is there any difference?
function distance(a, b)
if length(a) != length(b)
dist = 0
i = 1
while i <= length(a)
if a[i] != b[i]
dist += 1
i += 1
return keyword is useless and misleading. The following:
is a bit like
return sin("abc") # Some invalid code that throws an error
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.