Исключение быстрой принудительной развертки не распространяетсяIOS

Программируем под IOS
Anonymous
Исключение быстрой принудительной развертки не распространяется

Сообщение Anonymous »


I've run into this silly behaviour in swift where force-unwrapping an optional does not propagate.

From the documentation:

Trying to use ! to access a non-existent optional value triggers a runtime error. Always make sure that an optional contains a non-nil value before using ! to force-unwrap its value.

To reproduce:

func foo(bar:String?) throws{ print(bar!); } And

try foo(nil); This does not seem logical or consistent to me and I can't find any documentation on this subject.

Is this by design?


Источник: https://stackoverflow.com/questions/346 ... propagated

Вернуться в «IOS»