anyMatch

abstract fun anyMatch(predicate: Predicate<TextElement>): Boolean(source)

Tests whether any element in this sequence matches the given predicate.

This is a short-circuiting terminal operation: it stops as soon as a matching element is found and returns true immediately.

Examples:


// Check if list contains any comment
boolean hasComment = list.anyMatch(TextElement::isComment);

// Check if list contains any token with specific text
boolean hasIdentifier = list.anyMatch(el ->
    el instanceof TokenTextElement &&
    ((TokenTextElement) el).getText().equals("myVar")
);

Return

true if any element matches the predicate, false otherwise (returns false for empty sequences)

Parameters

predicate

the predicate to test elements against

Throws

if predicate is null