Skip to content

Latest commit

 

History

History
34 lines (26 loc) · 752 Bytes

offsets_of.md

File metadata and controls

34 lines (26 loc) · 752 Bytes
layout api-command
language Java
permalink api/java/offsets_of/
command offsetsOf
alias api/java/indexes_of/
io
sequence
array

Command syntax

{% apibody %} sequence.offsetsOf(datum | predicate_function) → array {% endapibody %}

Description

Get the indexes of an element in a sequence. If the argument is a predicate, get the indexes of all elements matching it.

Example: Find the position of the letter 'c'.

r.expr(r.array("a", "b", "c")).offsetsOf("c").run(conn);

Example: Find the popularity ranking of invisible heroes.

r.table("marvel").union(r.table("dc")).orderBy("popularity").offsetsOf(
    row -> row.g("superpowers").contains("invisibility")
).run(conn);