choose

Route a traverser to a particular traversal branch option.

Synopsis

choose(traversal,choice_1,choice_2,choice_3)
Table 1. Legend
Syntax conventions Description
Lowercase and uppercase Literal keyword. Includes ().
Italics Variable value. Replace with a user-defined value.
[] Optional. Square brackets ( [] ) surround optional command arguments. Do not type the square brackets.
{} Group. Braces ( {} ) identify a group to choose from. Do not type the braces.
| Or. A vertical bar ( | ) separates alternative elements. Type any one of the elements. Do not type the vertical bar.
... Repeatable. An ellipsis ( ... ) indicates that you can repeat the syntax element as often as required.

Description

The choose() step is a branch step that can be used to route a traverser to a particular traversal branch, similar to if-then-else logic.

Examples

g.V().hasLabel('store').as('store').
  V().hasLabel('ingredient').as('ingredient').
  choose(where(__.in('isStockedWith').as('store')),
           constant('Y'), constant('N')).as('in stock').
  select('store','ingredient','in stock').
    by('name').
    by('name').
    by()