class SomeClass {
var someProperty: Int {
throw Err("SNAFU")
}
}
For code like the above, the swift binary complains 'error is not handled because the enclosing function is not declared 'throws'.
How do I declare that 'someProperty' 'throws' in the above?
class SomeClass {
var someProperty throws: Int {
}
}
and
class SomeClass {
var someProperty: throws Int {
}
}
and
class SomeClass {
var someProperty: Int throws {
}
}
don't seem to work.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…