Not sure what you’re asking here: do you have a case where you can’t use a
return within an expression? One thing to note with your example above is
that only boolean values can be used in conditionals (i.e. if-statements,
&& and || operators, etc.), match returns the match contents if there was a
match, and the nothing value otherwise. So to make your case work, you’d
need something like:

captures = ismatch(regex,str) ? match(regex, str).captures : return

In Julia 0.4 dev branch, a Nullable type was recently merged and it’s been
discussed using a Nullable as the return type of regex operations which
would make it slightly easier to check for non-matches.

-Jacob
​

On Tue, Oct 21, 2014 at 3:52 AM, Till Ehrengruber <[email protected]>
wrote:

> wouldn't it be nice to be able to use the return statement deep inside
> your expression such that something like
>
> captures = (match(regex, str) || return).captures
>
> in this specific case i encountered a simple HttpRouter which just skips
> the current handler and i don't really need the other results of the match
> expression
>
> regards till
>

Reply via email to