Monday, February 8, 2016

From “Result” to “throw” and Back

Olivier Halligon:

Problem is, Result is not built in the Swift standard library, and a lot of functions use throw to report synchronous errors anyway. Like in practice, to build a User from a NSDictionary we might have a init(dict: NSDictionary) throws constructor instead of a NSDictionary -> Result<User> function.

So how to mix both those worlds? Easy: let’s extend Result just for that!

Comments RSS · Twitter

Leave a Comment