query
On this page

defaultTo

lib.trivial.defaultTo

Docs pulled from | This Revision | about 1 hour ago


Return maybeValue if not null, otherwise return default.

Inputs

default

1. Function argument

maybeValue

2. Function argument

Examples

lib.trivial.defaultTo usage example

defaultTo "default" null
=> "default"
defaultTo "default" "foo"
=> "foo"
defaultTo "default" false
=> false

Noogle detected

Aliases

Implementation

The following is the current implementation of this function.

defaultTo = default: maybeValue:
    if maybeValue != null then maybeValue
    else default;