1

我对重新投掷有疑问。以下代码在 Dictionary 扩展中:

init(_value: [(Key, Value)]) {
      self.init(_value, uniquingKeysWith: { _, first in first }) //Call can throw, but it is not           marked with 'try' and the error is not handled
    }

这里uniquingKeysWith不会抛出错误,因为我正在指定序列,仍然编译器告诉“调用可以抛出,但它没有用'try'标记并且错误没有被处理”

谁能解释我为什么在参数不抛出时需要为 init 处理错误?根据重新抛出的概念,如果参数 uniquingKeysWith 不会抛出错误,则方法不需要处理错误。

4

0 回答 0