Is there a way to get the index of all occurrences within a list?
Follow up to my first post why does this IndexOf return -1 when the item I am looking for is in the list?
Try the “List.AllIndicesOf” node.
About your second question, that’s just an oversight. Somebody just forgot that “-1” is a valid list index in DS:
Thanks for the reply, “List.AllIndicesOf” was what I was looking for. It unfortunately does not work if the list contains null values. I will put something together in the next couple of days and submit it to GH per your comment on my other post.
If you use Clockwork’s List.ReplaceNull, to replace all the nulls with “nulls” it will give you what you want. I dont know if this causes you problems further down your graph.
That would work and then I just look for “null”. I was trying to replace the null values with a matching index value from another list. Thats why I needed the index value. I ended up using an if statement and is value null. True use value from list B if false use value from list A.
Since many of the nodes do not take nulls I ended up replacing the null with a value the node would take and then placing the null back into the list after the node. Not very efficient but the only workaround I could think of at the time.
Thanks for the reply,
Alternatively, for this particular case, you could try the “NullAllIndicesOf” from spring nodes.
Wow did not know that was in spring nodes. thanks dimitar,