NthItem

See javadoc - uk.gov.gchq.koryphe.impl.function.NthItem

Available since Koryphe version 1.1.0

For a given Iterable, an NthItem will extract the item at the Nth index, where n is a user-provided selection. (Consider that this is array-backed, so a selection of "1" will extract the item at index 1, ie the 2nd item)"

Examples

Extract nth item

Java
JSON
Full JSON
Python
final NthItem<Integer> function = new NthItem<>(2);
{
  "class" : "NthItem",
  "selection" : 2
}
{
  "class" : "uk.gov.gchq.koryphe.impl.function.NthItem",
  "selection" : 2
}
g.NthItem( 
  selection=2 
)

Input type:

java.lang.Object

Example inputs:

Input TypeInputResult TypeResult
java.util.ArrayList[3, 1, 4]java.lang.Integer4
java.util.ArrayList[1, 5, 9]java.lang.Integer9
java.util.ArrayList[2, 6, 5]java.lang.Integer5
java.util.ArrayList[2, null, 5]java.lang.Integer5
java.util.ArrayList[2, 6, null]null
nullIllegalArgumentException: Input cannot be null

results matching ""

    No results matching ""