How to use defined functions as "predicate"?

Hi,

Why does the top workflow succeed with an OOTB node, while the bottom one tells me that my defined function ‘isequalto1()’ is not found?

I guess it makes sense, because according to my function definition, I have to feed it 1 argument so that it works. But then how does the OOTB node work? Does it have some kind of conditional clause to return the function itself if no arguments (or not enough of them) are supplied? Is there anyway to achieve the same in designscript?

(Ignore the top warning, it’s because of multiple definitions of List)

1 Like

there is no version of your function that takes no arguments - just use the name of your function without the () - that invokes it and returns the result - but you don’t have a version of that function which has no parameters - so thats the error.

get rid of the () - where you try to pass your function as a functionObject.

I did try that after I posted. I should have updated my post. It gives me a different error.

List.TrueForAny expects argument type(s) (var[]..[], Function), but was called with (int[], function).

you can do this with a hidden function - __CreateFunctionObject - which converts a function pointer to a Function object- see the implementation in DS here:

3 Likes

Ah interesting. I’ll have to play with this some more to understand it better. Thank you!

Are there commented versions of these files somewhere in the dynamo project?