Iterate() step is used in the end of the command when creating nodes and edges through function chaining. What is the use of this step?

Viewed 1858

Iterate() step is used in the end of the command when creating nodes and edges through function chaining in Tinkerpop 3.3/Gremlin. What is the significance of this iterate() step? I could not find any mention of the iterate() step in the documentation explaining its features. Could someone please point me to the documentation or provide an explanation about iterate() ? Link to iterate usage can be found here.

1 Answers

iterate() is one of the terminal steps that are used to actually execute a traversal. Without such a terminal step you are only getting back a traversal. Terminal steps like next() or iterate() actually execute this traversal.

iterate() is the terminal step that can be used when you don't want to return anything from the traversal. That's why it is used in the recipes to add data to the graph.

One thing to note is that the Gremlin Console executes traversals automatically for you even when they don't end in a terminal step. This can be a bit confusing to new users.

Related