|
|
|
|
|
by anorwell
4334 days ago
|
|
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. |
|
Should be easy to do the same in swift. Let me take a stab at it.