array →
single() → any

Returns the only element of the input array without transforming it. Returns null when the input is empty, contains more than one element, or cannot be evaluated as an array.

Parameters

This function has no parameters.

Behavior

single expresses an exact-cardinality requirement: the input must contain exactly one element. A sole null value is still the only element and therefore returns null; scalar and structured values retain their runtime type and value. Unlike first-elements(1), single returns an element rather than an array and rejects additional elements by returning null.

Examples

{42} | single  42
{} | single  #null
{1, 2} | single  #null

Kind: Function
Scope: array/selection
Aliases: None


This site uses Just the Docs, a documentation theme for Jekyll.