Skip to content

Instantly share code, notes, and snippets.

@alem0lars
Last active December 10, 2015 08:08
Show Gist options
  • Save alem0lars/4405944 to your computer and use it in GitHub Desktop.
Save alem0lars/4405944 to your computer and use it in GitHub Desktop.
Either + Maybe usage
Maybe([1,2,3]).select {|e| e < 3} # Just([1, 2])
Maybe([1,2,3]).select {|e| e < 0} # Nothing
Maybe([1,2,3]).select {|e| e < 3} # Just([1, 2])
Either(Maybe([1,2,3]).select {|e| e < 3}) # Success([1, 2])
Either(Maybe([1,2,3]).select {|e| e < 0}) # Failure(Nothing)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment