Sha256: c2172af22ed5786bc08cdb35598b4178525e3ff3b5e44121d2601be827aad788

Contents?: true

Size: 1.1 KB

Versions: 2

Compression:

Stored size: 1.1 KB

Contents

# OrElse

A simple implementation of the Maybe (Option) monad.

## Installation

Add this line to your application's Gemfile:

    gem 'or_else'

And then execute:

    $ bundle

Or install it yourself as:

    $ gem install or_else

## Usage

```ruby
value = Maybe(nil)        # => <OrElse::NothingClass>
value.empty?              # => true
value.nil?                # => true
value.exists?             # => false
value.map { |v| v }       # => <OrElse::NothingClass>
value.flat_map { |v| v }  # => <OrElse::NothingClass>
value.or_else { 'foo' }   # => 'foo'

value = Maybe('value')    # => <OrElse::Just>
value.empty?              # => false
value.nil?                # => false
value.exists?             # => true
value.map { |v| v }       # => 'value'
value.flat_map { |v| v }  # => 'value'
value.or_else { 'foo' }   # => 'value'
```

## Contributing

1. Fork it ( http://github.com/Originate/or_else/fork )
2. Create your feature branch (`git checkout -b my-new-feature`)
3. Commit your changes (`git commit -am 'Add some feature'`)
4. Push to the branch (`git push origin my-new-feature`)
5. Create new Pull Request

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
or_else-0.0.2 README.md
or_else-0.0.1 README.md