We read your photo as:

Which Kotlin collection function is used to create a new collection containing only the elements that satisfy a given condition?

Computer Science

ScanSolve AI Answer

Answer

filter()\text{filter()}

The correct option is filter().

In Kotlin, the filter() function is used to create a new collection containing only the elements from the original collection that satisfy a given predicate (a boolean-valued function or condition).

  • sort() is used to sort the elements of a collection.
  • map() is used to transform each element of a collection into a new form.
  • reduce() is used to combine all elements of a collection into a single result.

The final answer is filter()\text{filter()}

Was this helpful?

Try one yourself

A new problem that tests the same skill.

Still stuck on this one?

Ask a follow-up, and the answer starts from this question.

Got a different question?Ask your own question