first

fun first(): T

Returns the first element, or throws an exception if the list is empty. None-unique results may cause unexpected problems and are not recommended.

返回第一个元素,如果列表为空,则抛出异常。 非唯一结果可能会导致意外的问题,不推荐使用。


fun first(predicate: (T) -> Boolean): T

Returns the first element matching the given predicate, or throws an exception if no such element was found. None-unique results may cause unexpected problems and are not recommended.

返回与给定 predicate 匹配的第一个元素,如果未找到此类元素,则抛出异常。 非唯一结果可能会导致意外的问题,不推荐使用。