Comment

Comment by anorwell

You don't touch on the fact that options act can act Monads (i.e., that you can invoke an operation on the inner value, conditional on whether or not the optional value is present). For example, an optional user translates naturally to an optional user.name.

I haven't tried swift, and it's not obvious to me from the swift documentation if their options support arbitrary transformations, or just method chaining. In ruby (with ActiveSupport) this is the difference between:

      might_be_nil.try(:method)
and

      might_be_nil.try { |value| my_function(value) }
The latter is more general and useful than the former.
parent anorwell 12 years ago

Discussion

Live from the official Hacker News API

A modern reader for Hacker News · SvelteKit + Skeleton