构造函数要处理来自构造函数初始化式的异常,唯一的方法是将构造函数编写为函数测试块。
The only way for a constructor to handle an exception from a constructor initializer is to write the constructor as a function try block.
为什么呢?因为该代码块指定了在测试正确的情况下,我将进行的一系列操作。
Why? Because that block identifies a set of things that I'm going to do if the test is true.
结果和第一个测试结果相似:这个瘦演员拿了30块糖,参与者们也跟着拿糖,但拿的数量显然更多。
The results were similar to the first test: the participants followed suit but took significantly more candy when the thin actor took 30 pieces.
应用推荐