Suppose I have a script Foo.r
which looks like this.
source('Bar.r')
print("Hello World")
Now suppose further that in Bar.r
, I want to return immediately if some condition is true, instead of executing the rest of the script.
if (DO_NOT_RUN_BAR) return; // What should return here be replaced with?
// Remainder of work in bar
In particular, if DO_NOT_RUN_BAR
is set, I want Bar.r
to return and Foo.r
to continue execution, printing Hello World
.
I realize that one way to do this is to invert the if
statement in Bar.t
and wrap the entire script inside an if
statement that checks for the logical negation of DO_NOT_RUN_BAR
, but I still want to know whether I can replace the return
statement in the code above to skip execution of the rest of Bar.r
when it is sourced.