`$select` Support
RDIL opened this issue · comments
Add support for that wacky node that Govert found.
What does it actually do?
The $select
action runs an action for every element in an array that matches a condition
Syntax is like this
"$select": {
"in": [1, 2, 3],
"?": {
"$gt": ["$.#", 1]
},
"!": [
"$inc": ["$.myvariable", "$.#"]
]
This would add the values 2 and 3 to the context var myvariable
There are no official contracts or challenges that use it, and afaik the functionality was added in H3.
That's actually really nice, I like that.
Question: what happens if you just put a number for in
, does it just not do anything?
I'm not entirely sure, but I think it'll crash during loading.
You can do "in": "$.contextVar"
, just like you can with $all
, $any
, and $inarray
, to use a context var as input array and I think that will do nothing if contextVar is not an array.
I don't have all the behaviour written down yet, so this might be incorrect.