I have noticed double underscore being used in some step functions in Tinkerpop Gremlin 3.3. Could someone please tell why we use this double underscore with an example ? I could not find enough information about this in the documentation.
__.
allows you to define an anonymous Traversal
, ie. a Traversal
which is not bound to a specific TraversalSource
.
In the Gremlin console, all Gremlin steps are statically imported so you never need to prefix anonymous traversals with __.
unless that anonymous traversal starts with a reserved keyword in the target language. In Groovy, which is the default Gremlin flavor, this is the case with in()
and as()
steps: because these are reserved keywords, these two steps must be prefixed with __.
In Java, you can avoid __.
prefix by statically importing all steps in your program:
import static org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.__
See the small Note section in the documentation: http://tinkerpop.apache.org/docs/3.3.0/reference/#graph-traversal-steps
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With