A

Admin • 833K Points
Coach

Q. What is the use of the `takeIf()` function?

  • (A) Always returns true
  • (B) Returns the object if condition is true, else null
  • (C) Takes the first element of a list
  • (D) Returns false if condition is false
  • Correct Answer - Option(B)
  • Views: 16
  • Filed under category Kotlin
  • Hashtags:

Explanation by: Admin

takeIf returns the object if the predicate is true, otherwise null.

You must be Logged in to update hint/solution

Discusssion

Login to discuss.

Be the first to start discuss.