List.IndexOf returning null or -1 depending on the Dynamo version

I’ve run into a problem with a script between Dynamo versions 2.19 and 3.3. Typically I do a save as from 2,19 and open the script in 3.3, update to the packages relevant for 3.3.

However, we’ve run into a problem with one script not working the same between 2.19 and 3.3, and I’ve realized the List.IndexOf gives different results when out of range.

In 2.19 I get a -1, see index 2.

While in 3.3 the result is a null, see below

Is this known behavior, are there any other nodes which are like this and have different outputs between Dynamo versions?

Yes, and yes.

See the release notes for insights on changes of behavior, including this note in 3.3: Release Notes · DynamoDS/Dynamo Wiki · GitHub.

If you wanna get rid of ‘that’ you could use List.AllIndicesOf.

I need to keep a better eye on the release notes!

@bvs1982 I will make this change.

I’m happy I noticed this going wrong now and that I’m aware of it, will have to look back on a few old scripts to check for it.

1 Like