Code Block logic

Hey gang,

I’m painfully aware of how simple these questions are. please bear with me for a few more weeks/months until I get accustomed to it.

Can someone explain to me what this code block here is trying to say/do ?

Kind regards,
LL

n

The code block a[0]; is taking the variable a which is undefined and therefore treated as an input to the node) and pulling the first item out of the list. My guess is it is throwing a warning here as ‘a’ isn’t a list.

The [0] but is the part that is taking items out of the list. This is indexing and versions of it are used in DesignScript, Python, C#, and other languages so it is good to learn. In Design Script the brackets indicate you want to work with a portion of the collection, while the number indicates the index which you want to take out of the list.

2 Likes

To illustrate what Jacob said:

image

4 Likes