This feature hasn't been implemented as of Apache TinkerPop 3.4.2. It is a long standing open issue: TINKERPOP-1084. I think that if you want this functionality, you're going to have do a nested choose()
:
gremlin> g = TinkerFactory.createModern().traversal()
==>graphtraversalsource[tinkergraph[vertices:6 edges:6], standard]
gremlin> g.V().hasLabel('person').
......1> choose(values('age').is(lt(29)),
......2> constant('lt29'),
......3> choose(values('age').is(gt(29)),
......4> constant('gt29'),
......5> constant('29')))
==>29
==>lt29
==>gt29
==>gt29
Note that you aren't restricted to constant()
as a result of these nested choose()
operations. You can add any anonymous traversal you like there as in:
gremlin> g.V().hasLabel('person').
......1> choose(values('age').is(lt(29)),
......2> constant('lt29'),
......3> choose(values('age').is(gt(29)),
......4> math('_ - 29').by('age'),
......5> constant('29')))
==>29
==>lt29
==>3.0
==>6.0