elementAt

fun YamlElement.elementAt(pointer: KPointer): YamlElement?(source)

Returns the YamlElement at the path identified by pointer, or null if a key along the path is absent.

Dispatches by concrete subtype: navigates into YamlMap and YamlList via the adapter machinery; returns the receiver for the root pointer on a YamlPrimitive; throws for any non-root pointer on a YamlPrimitive or when the path requires navigating through a primitive.

No operator fun get(KPointer) is provided because YamlMap declares operator fun get(key: Any?): YamlElement? directly, which would shadow any such extension and silently return null for a KPointer argument. Pointer-based access goes through elementAt (and the typed variants mapAt, listAt, primitiveAt) instead.

Return

The YamlElement at the specified path, or null if a key along the path is absent.

Parameters

pointer

The KPointer identifying the value to retrieve.

Throws

if an intermediate segment lands on a primitive, or pointer is non-root and the receiver is a YamlPrimitive.


fun YamlElement.elementAt(path: String): YamlElement?(source)

Parses path via KPointer.from and returns the YamlElement at that path, or null if absent.

Return

The YamlElement at the specified path, or null if absent.

Parameters

path

A pointer string (RFC 6901, fragment, or dot-notation, dispatched by prefix).

Throws

if path is not a valid pointer string.