Swift: should a function Throw or return an Optional?

Since Swift 2.0 we now have two ways for a function to fail: It can return an Optional Or it can Throw Let’s use a very simple example: a function to return the square root of a number. It is supposed to fail if the number was negative of course. Return an Optional

Throw an exception


Continue reading →