Skip to content

Conversation

@rap1ds
Copy link
Owner

@rap1ds rap1ds commented Aug 25, 2014

Release 0.3.0

Breaking changes

  • or_else is renamed to get_or_else. This change unifies the API naming. All the methods that start with get_ return the unwrapped value. Migration: Go through your project and replace all or_else methods calls to get_or_else

Additions

  • The new or_else method: Returns the current Maybe if it's Some, otherwise it returns what is given as a parameter.
Maybe("a").or_else { Maybe("b") }.map(&:upcase) # => "A"
Maybe(nil).or_else { Maybe("b") }.map(&:upcase) # => "B"
  • combine: Takes two Maybes and returns a new Maybe which contains and array of the values of the two combined Maybes.
Maybe(14).combine(Maybe(23)).map { |(a, b)| a + b }.get # => 37
  • inner: Forwards the method call straight to the value. This is especially useful if the value is an array.
Maybe([1, 5, 3, 7, 9, 6]).inner.max.get # => 9
  • lazy: Maybe can be used lazily. You can call lazy to any Maybe and get back a lazy version. Also, you can initialize a new Maybe lazily by giving it a block. In 0.3.0, lazy is opt-in, but the plan is to make it a default in the future versions.

@rap1ds rap1ds mentioned this pull request Nov 24, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants