To indicate that a function or method can throw an error, we write the
throws
keyword in its declaration.How would we indicate this for computed properties. For example:
public var isSuccess: Bool {
if let r = result {
switch r {
case .Success: return true
case .Failure: return false
}
}
else {
throw FutureError.NotCompleted
}
}
According the documentation, it seems it is not (yet) implemented.
Possibly, it may read as this (does not compile):
public var isSuccess throws: Bool {
if let r = result {
switch r {
case .Success: return true
case .Failure: return false
}
}
else {
throw FutureError.NotCompleted
}
}
public var isSuccess: Bool { get throws {
if let r = result {
switch r {
case .Success: return true
case .Failure: return false
}
}
else {
throw FutureError.NotCompleted
}}
}