arangodb/java-velocypack

provide documentation on how to create single element slice

beoliver opened this issue · 1 comments

Excuse the code (working with Clojure)
As a slice can contain a single element.

(-> (new VPackBuilder)
    (.add ValueType/OBJECT)
    (.add "foo" "bar")
    .close
    .slice
    (.get "foo"))

#object[com.arangodb.velocypack.VPackSlice 0x2b9072bd "\"bar\""]

Is there a canonical way of creating a single element slice?

(-> (new VPackBuilder)
    (.add ValueType/ARRAY)
    (.add "bar")
    .close
    .slice
    (.get 0))

#object[com.arangodb.velocypack.VPackSlice 0x1eb0779a "\"bar\""]

You can just write

(-> (new VPackBuilder)
    (.add "bar")
    .slice