We read your photo as:

Which Kotlin function allows you to filter elements of a collection based on a specified condition.

Computer Science

ScanSolve AI Answer

The question asks which Kotlin function allows you to filter elements of a collection based on a specified condition.

Let's look at the options:

  • sort(): This function is used to arrange the elements of a collection in a specific order (ascending, descending, or custom).
  • map(): This function transforms each element in a collection into a new element, creating a new collection of the transformed elements.
  • filter(): This function creates a new collection containing only the elements from the original collection that satisfy a given condition (a predicate).
  • reduce(): This function applies an operation to the elements of a collection sequentially and accumulates the result into a single value.

Based on the definitions, the filter() function is specifically designed to select elements from a collection that meet a certain condition.

The correct option is:

  • filter()
Was this helpful?

Still stuck on this one?

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

Got a different question?Ask your own question