A Maybe object can contain either nil or some other object, and allows to construct calculations without knowing this other object yet. If the calculation fails, due to a loop or a not yet defined object, Maybe returns nil.
The name Maybe stems from the programming language Haskell, where it represents a somewhat similar entity. See also: Fdef
put, addAll, add, putAll, atAll.
You can extend Maybe as you need for your purpose, by the following schema:
create a new instance
an object or nil.
return or set the contained object
set the contained object or return the source, or the value of the contained object, if it is a Maybe. If there is a recursion, return nil.
return the value, or the value of the contained object, if it is a Maybe. This method allows recursion, so that recursive calculations can be made.
(called by any message that Maybe doesn't understand.)
returns a composition function that, when evaluated, returns the value.