getOrElse

Extracts the value of a Maybe structure, if it exists (i.e.: is a Just), otherwise returns the provided default value.

Signature

forall a: (Maybe a).(a) => a

Documentation

Extracts the value of a Maybe structure, if it exists (i.e.: is a Just), otherwise returns the provided default value.

Example:

const Maybe = require('folktale/maybe');

Maybe.Just(1).getOrElse(2);   // ==> 1
Maybe.Nothing().getOrElse(2); // ==> 2

Properties

Source Code

Defined in source/maybe/maybe.js at line 57, column 18
{
    /*~*/
    Nothing: function getOrElse(_default) {
      return _default;
    },

    /*~*/
    Just: function getOrElse(_default) {
      return this.value;
    }
  }
Licence
MIT
Module
folktale/maybe/maybe
Authors
Copyright
(c) 2013-2017 Quildreen Motta, and CONTRIBUTORS
Authors
  • Quildreen Motta
Maintainers
  • Quildreen Motta <queen@robotlolita.me> (http://robotlolita.me/)