Function as parameter


This sounds more like a javascript or typescript question, but I was able to do it in other environments but not in ZapWorks. I want to do this:

function toggle(...args: Function[]) {
    args.forEach((arg) => {arg() === true ? arg(false) : arg(true)});

toggle(node1.enabled, node2.visible);

I want to pass a bunch of functions that returns false or true with no arguments, and if it’s true it calls the function with false and vice versa. I know I could do this with states or just do something more specific like this:

function toggle() {
  node1.enabled() === true? node1.enabled(false):node1.enabled(true);

But really it’s not the way I want.