Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Release 0.3.0 #11

Open
wants to merge 16 commits into
base: master
Choose a base branch
from
Open

Release 0.3.0 #11

wants to merge 16 commits into from

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.

1 participant