The current Swift 2 compiler doesn’t allow a subscript operator to throw exceptions; at least, if I declare it like this:
public subscript(name: String) throws -> Something? { … }
I get the familiar “Consecutive declarations on a line must be separated by ‘;’” error at the “throws” keyword.
Is this an intentional design limitation, or just a compiler bug?
In my case, the subscript operator is looking up a value from a database given its key, so there are various ways it could fail aside from there not being a value.
—Jens