Options
All
  • Public
  • Public/Protected
  • All
Menu

External module "utils/if-else/docs/types/index.d"

Index

Functions

Functions

Export assignment ifelse

  • ifelse<T, U>(bool: boolean, x: T, y: U): T | U
  • If a condition is truthy, returns x; otherwise, returns y.

    Type parameters

    • T

    • U

    Parameters

    • bool: boolean

      condition

    • x: T

      value to return if a condition is truthy

    • y: U

      value to return if a condition is falsy

    Returns T | U

    either x or y

    Example

    var randu = require( '@stdlib/random/base/randu' );
    
    var z = ifelse( randu() > 0.5, 1.0, -1.0 );
    // returns <number>