Dynamo: List.Contains versus Contains

headercontains

When you want to check if an element exists in a list there are actually 2 nodes you can use:
contains

They look the same: same input ports and same output port, but the behavior is different.

Contains will look for the item in any sublist of the given list. List.ContainsItem will only look on the specified level.

Here an example:

containsex

The string “X” is defined in a sublist of a sublist of a sublist of the input list. Contains will look in any sublist of the given list and will report “true”.

On the other hand “List.ContainsItem” will only look for the item on the first level which is level 5, where only the values 1,2,3, a sublist, 5 and 6 are defined. So the node is reporting false.

level5

The only way for “List.ContainsItem” to find the string “x” is to define the exact level to search in:

level2

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s