Nested if statement not working

hello, any idea why I cant get this nested if statement to work? if checked the syntax. I think it should be right…? what gives?

You need x==null instead of x=null.

i tried that as well. doesnt recognize nulls nor does it process past the first question mark:

I had similar issues, it kept warning me about ‘rank reduction’ using most methods. The null values seem to throw off the if statement, even if it gets caught in the first if it seems to get messed up by the second one as a null cannot make it through a > statement.

This is a very long-winded method that can probably be simplified, but I turned the null list into strings as a means of managing them using some logic:

It looks like you’re on an older version of Dynamo (1.3 probably). Your If statement isn’t even returning the correct number of results, which is why there would be rank reduction issues, but I didn’t have a problem in 2.3.

Edit: Looks like it works for me in 1.3 as well.
You might try recreating that entire codeblock. I’ve seen DS get stuck if you go back and forth between valid and invalid syntax too much without letting Dynamo reevaluate the entire block.

Either way, a nested If statement is still just two If statements. You can always break them apart.


@Nick_Boyts I am sure it works on your end, but its definately not working for me. I create these from scratch, still the same results:

@GavinCrump I like what you did there, except I dont think its working the way you intended. shouldnt these values be true if it was working properly?

In that image you have values at varying list levels. In previous versions, that’s going to error due to rank reduction no matter what you do. The If statement has nothing to do with it. I don’t know how easy it’s going to be to deal with that in 1.3.

Hrm yes looks like rank reduction still got me or I misstepped.

This method’s a bit more explicit/brute and seems to work:

1 Like

Not sure if this works the same in the version of Dynamo you’re using. In 2.12.X pushing the conditional statement through a function works like this…

The original list structure is partially lost though

def bln (x:var[][])
	return = x==null ? true:x < 0 ? true :false;

Design script wizardry as always! Loved your segment in the generative design webinar as well, just watched it - amazing stuff.

1 Like