Skip to content

Instantly share code, notes, and snippets.

View alem0lars's full-sized avatar
💭
corrupting memory

Alessandro Molari alem0lars

💭
corrupting memory
View GitHub Profile
@alem0lars
alem0lars / either_maybe_usage.rb
Last active December 10, 2015 08:08
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)