Syntax to get the first element that matches the predicate fun List.firstOrNull( Returns the first element if the ArrayList is not empty. Syntax to get the first element // to get first element If no element matches the provided predicate function, then null is returned. ![]() To get the first element of the ArrayList that satisfies the provided predicate function Predicate is a Functional interface, which takes one argument and returns either true or false based on the condition defined.If the ArrayList is empty, then null is returned. ![]() To get the first element of the ArrayList.The firstOrNull() method can be used in two ways.
0 Comments
Leave a Reply. |