If you think about, Java/C# always had that Option, is only called Iterable[T]/IEnumerable[T]: either you have one element inside or not.
So I've done another implementation in java. In comparison with the 'other' implementation:
- instead of the slower 'instanceof' matching, we use a boolean hasValue()
- almost as in F#, the Option implements the Iterable
ps. A lot of people like the 'scala Option' or the 'F# Option'.
pps. My favorite 'What is a Monad?' explanations are the Brian Beckman - "Don't fear the Monads" video, and the Wes Dyer "The Marvels of Monads" blog-entry. Here the other links.
No comments:
Post a Comment