i just want to return from the function. i often encounter the problem 
where i need just one property out of a function result and want to return 
from the current function if the function contains "no data". this is e.g. 
usefull if you encapsulate data and status of your result into a special 
result type.

Am Dienstag, 21. Oktober 2014 23:28:31 UTC+2 schrieb Stefan Karpinski:
>
> Do you want the return to return from the function or do something else?
>
> On Tue, Oct 21, 2014 at 5:22 PM, Till Ehrengruber <[email protected] 
> <javascript:>> wrote:
>
>> what jacob already suggested as a working solution
>>
>> captures = ismatch(regex,str) ? match(regex, str).captures : return
>>
>> i can live with that but i would like to express this without the ismatch 
>> but still in a single line
>>
>> Am Dienstag, 21. Oktober 2014 21:41:35 UTC+2 schrieb Stefan Karpinski:
>>>
>>> What do you want your original example to do?
>>>
>>> On Oct 21, 2014, at 3:39 PM, Till Ehrengruber <[email protected]> 
>>> wrote:
>>>
>>> ah i see. I'm a bit confused about conditionals since
>>>
>>> false || nothing
>>>
>>> for example works alright but
>>>
>>> nothing || false
>>>
>>> does not. Since the last one doesn't work like I expected my question is 
>>> pretty senseless ^^ But still i like the used syntax as this doesn't need 
>>> another function (like the `ismatch`) which can be pretty nasty to 
>>> implement when the computation is havy and you want to cache the result. Is 
>>> there any specific reason that conditionals aren't "symmetric"?
>>>
>>> Can't see the benefit of the nullable type in this case can you tell?
>>>
>>> Am Dienstag, 21. Oktober 2014 14:39:12 UTC+2 schrieb Jacob Quinn:
>>>>
>>>> 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