I am experimenting with the traversal examples from the TinkerPop3 documentation. Having loaded up the classic graph with g = TinkerFactory.createClassic(), at the Gremlin shell:
gremlin> marko = g.v(1)
==>v[1]
gremlin> marko
==>v[1]
However:
gremlin> marko = g.V().has('name', 'marko')
==>v[1]
gremlin> marko
gremlin>
Why does the second form not capture v[1]?
Given the second form, attemping to use the variable results in an error:
gremlin> marko.out('knows')
The traversal strategies are complete and the traversal can no longer have steps added to it
Display stack trace? [yN]
You're dealing with different class types from each of those results. Consider my console session below:
The above yields a
Vertexbut as you can see below:you get a
Traversalinstance. You see output to the console ofv[1]because the console has automatically iterated the result for you. Since you have iterated it,markobecomes empty:If you want to manually iterate then do this: