Quantcast
Channel: First steps - JuliaLang
Viewing all articles
Browse latest Browse all 2795

A Julia equivalent to R's stop()?

$
0
0

@vlandau wrote:

Is there an equivalent in Julia to the stop() function in R? The nice thing about stop() is that it can be run from any scope (e.g. a function within a function) and it will throw an error and terminate the function that the user called.

I see that throw() in Julia does something similar, but I’d like to avoid printing a stack trace because it is not necessary for the info I’m trying to convey to users (e.g. two arrays provided as arguments are not the same size, but they need to be)

For now, I’m doing things like:

there_is_an_error = check_for_the_error(arg1, arg2) # returns a Bool
there_is_an_error && (@error "error message"; return)

I’d like to be able to have everything contained inside of check_for_the_error() to make the code more tidy.

Also open to suggestions for different approaches entirely.

Thanks!

Posts: 10

Participants: 5

Read full topic


Viewing all articles
Browse latest Browse all 2795

Latest Images

Trending Articles



Latest Images