PHP7.1介绍了一种将异常处理代码重用到多个异常类型的方法。
https://wiki.php.net/rfc/multiple-catch
<?php
try {
// Some code...
} catch (ExceptionType1 | ExceptionType2 $e) {
// Code to handle the exception
} catch (\Exception $e) {
// ...
}Swift 3是否提供了类似的方法,例如在catch表达式中使用where子句?
发布于 2016-10-11 09:01:56
你可以试试这个:
catch let error where error is ErrorType1 || error is ErrorType2https://stackoverflow.com/questions/39973561
复制相似问题