Is it correct that if[cond;…] will not return a value, but $[cond;;] will?
In my experience this is the case.https://code.kx.com/trac/wiki/QforMortals/execution_control explainsif and $ further.On Jul 8, 6:24?pm, K4 Monk <k4m…> wrote:> Is it correct that if[cond;…] will not return a value, but $[cond;;]> will?</k4m…>
On Jul 8, 2011, at 1:24 PM, K4 Monk wrote:
> Is it correct that if[cond;…] will not return a value, but
$[cond;;] will?
if does not inherently return anything leftwards
you can set variables from inside it, or if you’re in a function, you
can return from the function
$ returns the last value from the block executed (i.e. the result, if
it’s a single statement, or the last statement in the block, if it’s a
compound)
On 9 Jul 2011, at 04:47, Aaron Davies wrote:
> On Jul 8, 2011, at 1:24 PM, K4 Monk wrote:
>
>> Is it correct that if[cond;…] will not return a value, but
$[cond;;] will?
>
> if does not inherently return anything leftwards
I think it is better to say that it always returns (::)
q)a:if[1]
q)b:if[0]
q)a~b
1b
q)(::)~a
1b
Cheers,
Attila