You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tinkerpop.apache.org by ok...@apache.org on 2015/06/12 14:06:26 UTC

[2/4] incubator-tinkerpop git commit: TINKERPOP3-723: Add constant step doc

TINKERPOP3-723: Add constant step doc


Project: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/commit/7f8274c9
Tree: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/tree/7f8274c9
Diff: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/diff/7f8274c9

Branch: refs/heads/master
Commit: 7f8274c9887fb0237118afb4b9e935f4999d7dd8
Parents: d309af6
Author: mhfrantz <mf...@redsealnetworks.com>
Authored: Thu Jun 11 19:02:35 2015 -0700
Committer: mhfrantz <mf...@redsealnetworks.com>
Committed: Thu Jun 11 19:02:35 2015 -0700

----------------------------------------------------------------------
 docs/src/the-traversal.asciidoc | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/7f8274c9/docs/src/the-traversal.asciidoc
----------------------------------------------------------------------
diff --git a/docs/src/the-traversal.asciidoc b/docs/src/the-traversal.asciidoc
index a334a10..7f5793d 100644
--- a/docs/src/the-traversal.asciidoc
+++ b/docs/src/the-traversal.asciidoc
@@ -419,6 +419,25 @@ g.V().coin(0.0)
 g.V().coin(1.0)
 ----
 
+[[constant-step]]
+Constant Step
+~~~~~~~~~~~~~
+
+To specify a constant value for a traverser, use the `constant()`-step (*map*).  This is often useful with conditional steps like <<choose-step,`choose()`-step>> or <<coalesce-step,`coalesce()`-step>>.
+
+[gremlin-groovy,modern]
+----
+g.V().choose(__.hasLabel('person'),
+    __.values('name'),
+    __.constant('inhuman')) <1>
+g.V().coalesce(
+    __.hasLabel('person').values('name'),
+    __.constant('inhuman')) <2>
+----
+
+<1> Show the names of people, but show "inhuman" for other vertices.
+<2> Same as statement 1 (unless there is a person vertex with no name).
+
 [[cyclicpath-step]]
 CyclicPath Step
 ~~~~~~~~~~~~~~~