Skip to content

Instantly share code, notes, and snippets.

@lautis
Created October 22, 2012 17:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lautis/3932742 to your computer and use it in GitHub Desktop.
Save lautis/3932742 to your computer and use it in GitHub Desktop.
class Some
initialize: (@value) ->
getOrElse: -> @value
filter: (f) ->
if f @value
new Some(@value)
else
None
map: (f) ->
f @value
isDefined: true
flatMap: (f) ->
f @
None =
getOrElse: (value) -> value
filter: -> None
map: -> None
flatMap: (f) ->
f None
isDefined: false
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment