concept condition in category kotlin

appears as: conditions, condition, conditions, condition, The condition
The Joy of Kotlin

This is an excerpt from Manning's book The Joy of Kotlin.

  • Finding conditions that should hold
  • Finding conditions that shouldn’t hold
  • Write a function filter taking a condition that’s represented by a function from A to Boolean and returning a Result<A>, which will be Success or Failure, depending on whether the condition holds for the wrapped value. The signature will be this:

    fun filter(p: (A) -> Boolean): Result<A>

    Create a second function taking a condition as its first argument and a String as a second argument, using the string argument for the potential Failure case.