Packages

c

cats.syntax

IfApplyOps

final class IfApplyOps[F[_]] extends AnyVal

Source
apply.scala
Linear Supertypes
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. IfApplyOps
  2. AnyVal
  3. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. All

Instance Constructors

  1. new IfApplyOps(fcond: F[Boolean])

Value Members

  1. final def !=(arg0: Any): Boolean
    Definition Classes
    Any
  2. final def ##(): Int
    Definition Classes
    Any
  3. final def ==(arg0: Any): Boolean
    Definition Classes
    Any
  4. final def asInstanceOf[T0]: T0
    Definition Classes
    Any
  5. def getClass(): Class[_ <: AnyVal]
    Definition Classes
    AnyVal → Any
  6. def ifA[A](ifTrue: F[A], ifFalse: F[A])(implicit F: Apply[F]): F[A]

    An if-then-else lifted into the F context.

    An if-then-else lifted into the F context. This function combines the effects of the fcond condition and of the two branches, in the order in which they are given.

    The value of the result is, depending on the value of the condition, the value of the first argument, or the value of the second argument.

    Example:

    scala> import cats.implicits._
    
    scala> val b1: Option[Boolean] = Some(true)
    scala> val asInt1: Option[Int] = b1.ifA(Some(1), Some(0))
    scala> asInt1.get
    res0: Int = 1
    
    scala> val b2: Option[Boolean] = Some(false)
    scala> val asInt2: Option[Int] = b2.ifA(Some(1), Some(0))
    scala> asInt2.get
    res1: Int = 0
    
    scala> val b3: Option[Boolean] = Some(true)
    scala> val asInt3: Option[Int] = b3.ifA(Some(1), None)
    asInt2: Option[Int] = None
  7. final def isInstanceOf[T0]: Boolean
    Definition Classes
    Any
  8. def toString(): String
    Definition Classes
    Any

Inherited from AnyVal

Inherited from Any

Ungrouped