Can I name the result of an anonymous traversal without moving the traverser?

I can currently do the following:

Graph graph = TinkerFactory.createModern();

GraphTraversalSource gts = AnonymousTraversalSource.traversal().withEmbedded(graph);

gts.V().hasLabel("person")
        .has("name", "josh")
        .where(__.out().has("name", "ripple"))
        .project("rippleCreatorName", "rippleName", "rippleLang")
        .by("name")
        .by(__.out().has("name", "ripple").values("name"))
        .by(__.out().has("name", "ripple").values("lang"))
        .toList();


I wish I could do something like this instead:

Graph graph = TinkerFactory.createModern();

GraphTraversalSource gts = AnonymousTraversalSource.traversal().withEmbedded(graph);

gts.V().hasLabel("person").has("name", "josh")
        .let("ripple", __.out().has("name", "ripple"))
        .project("rippleCreatorName", "rippleName", "rippleLang")
        .by("name")
        .by(__.select("ripple").values("name"))
        .by(__.select("ripple").values("lang"))
        .toList()


What would you recommend to me? I only want to do __.out().has("name", "ripple") once, because in my project this filter is much longer so there is considerable repeated code.
Solution
You could perhaps play around with store
gremlin> g.V().hasLabel("person").
......1>       has("name", "josh").
......2>       where(__.out().has("name", "ripple").store('a')).
......3>       project("rippleCreatorName", "rippleName", "rippleLang").
......4>       by("name").
......5>       by(select('a').unfold().values("name")).
......6>       by(select('a').unfold().values("lang"))

==>[rippleCreatorName:josh,rippleName:ripple,rippleLang:java] 
Was this page helpful?