

“What does var[]..[] mean?”

My grandfather was a PhD Chemist at NASA, and his daughter, my mother, used to complain that he always over-explained: when asked what time it was, my grandpa would first explain how a clock worked. Perhaps obnoxiousness skips a generation…? Here’s my over-explanation.

You’re definitely my type

When nodes in Dynamo consume data, they may require a certain type of data and a certain structure. We’ll get to structure below, but data types are fundamental for programming languages to operate sensibly. A type is exactly what it sounds like: a different kind of data. Here are some common ones that show up in Dynamo:


Common Type Which Means…
Int32 A.K.A.:   Integer,   32-bit Integer,   int.
These are whole numbers. More here.
Double A.K.A.:   number,   double precision value
Any number that has decimal places like 3.14, 1.00. More here.
String A.K.A.:   text,   character string
More here.
Boolean A.K.A.:   bool
This is basically either “true” or “false.” More here.
StackValue A.K.A.:   Function,   _SingleFunctionObject
Believe it or not, even Dynamo functions are a type of data. They can be called different things like “f(x)“, “combinator“, or the like, but it just means that the type of the “data” is actually a function.
var Absolutely anything. This is just generic data.* More here.
*Did you catch that?! We’re half-way to explaining var[]..[].


After the basic set of data types above, other special types like Point, Line, Circle are relatively easy to identify. New Dynamo libraries or packages may also introduce new types of data. For example, the Revit library its own data types like Element, FloorType, and Sheet.




Note, too, that data types have short names and long names. We might call a piece of text a “String,” but the full name is System.String. It works like this with species too. It’s faster to say that my friend Fido is a dog, but more properly, he’s a Canis lupus. And we could get even more proper if we used the Object.Type node on him.




Why does this matter? Because 3.00 + 10 (which is a Double plus an Integer) makes sense, but 3.00 + Wednesday (a Double plus a DayOfWeek) does not make sense, so Dynamo says “null”.




Something else happened with the first example; a computer won’t actually let you add an Integer and a Double, but the + node is smart enough to “cast”, or change, 10 the Integer to 10.00 the Double.

Read more on data types in the Primer: 4-1 Data.

Structurally speaking

There are really only two data structures in Dynamo: an item and a list, and the only difference is that a list is a container for other items. A list can also contain other lists.

In general, there are really just 4 circumstances where data structure is meaningful to out-of-the-box Dynamo nodes. These are:


item list list of lists arbitrary structure
Pez Pez[] Pez[][] Pez[]..[]
list listOfLists aribraryStructure
Just a single thing. A thing that contains other things. A 2-dimensional structure; think of rows and columns. I mean, I don’t know how to describe this one either…


Have you noticed those [] characters in the tooltips for input and output ports on Dynamo nodes? It’s not just because something didn’t load correctly. They are there to tell you what the node wants in order to operate. Consider the PolyCurve.ByPoints node. It needs a list of points because you need at least two points to make a line, and it needs a single true or false value to decide whether to make the polycurve a closed shape.




This structural distinction matters because it tells the node how to replicate, or, how many times it should execute. If I give the PolyCurve.ByPoints node more than it asks for, then I will get more than one result. The Point port only wants a single list, so if I give it a list of lists—data with the type and structure Point[][]—the node will execute multiple times, producing multiple results.




The Excel.Write node is an example where a list of lists is required for the data input. The data must be exactly two dimensions because an Excel spreadsheet only has rows and columns of cells where each cell can only take one thing—no third dimension is allowed, so data structured like var[][][] just won’t do.

Why var? Because this node is flexible: you can write Strings, Integers, Doubles and some other types of data to Excel.




And finally to var[]..[]. You will see this most often in Dynamo with nodes that act on lists generically. Flatten, for example, must act to flatten the structure of absolutely anything you throw at it, no matter what’s inside or what it was structured like before.




That also means that Flatten will never replicate, or produce multiple results based on the structure of the information you pass in. You will only ever get one list out

unless you force the node to work on a different level of the list. And that, Dear Reader, is why we have



Image credit