I am learning Swift. I am designing a class that needs to do parameter validation in it's initializer. How should I handle this if the value passed falls out of range ? I am really finding it difficult to find an appropiate way to design this, considering that:
- Swift does not have exceptions, in languages with exceptions and built-in try/catch mechanism, I would have thrown an exception.
- Swift does not allow returning nil / null / nothing from the initializer to indicate an error condition, like we can do in Objective-C.
- I feel passing an NSErrorPointer to an initializer is cumbersome and places an unneccessary burden on the consumer of the class.
How would you validate a parameter for an initializer in Swift ?