I found a bit of behavior I found unintuitive and wanted to highlight it, since it took me a bit of time to understand and work around. Apologies if this is already a known factor.
First: The empty list () evaluates to false.
But also: !() evaluates to false.
I think what’s happening here is that !, as a unary operator, is propagated to every element of the list. For the empty list, the result of that operation is the empty list. The reason this came up is because I was trying to test for the presence of a value in a Decker grid, like so:
extract where index=idx from grid.value
This returns a list that contains the value of the first column where index=idx if it exists and an empty list if it doesn’t. I only wanted to take action if there was no entry, so I tried to negate it like so…
if !(extract where index=idx from grid.value)
# do something
end
…which didn’t work. So now I’m using my workaround:
if extract where index=idx from grid.value
0 # essentially a no-op here
else
# do something
end
…which does work.