Avoid concrete fields in traits that can't be initialized to suitable default values.
在trait里避免不能用合适的默认值初始化的具体字段。
Note that, in this example, sum must be initialized to an explicit floating-point value; otherwise, all the subsequent computations will be done using integer arithmetic.
注意,在本例中,sum 必须被初始化为一个显式的浮点值;否则,所有后续计算都将使用整数运算计算。
All right. Second question: or maybe a better way of saying this, and the general format you're likely to see here is, a test involving a variable name, which must be initialized outside of the loop, and which interior to the loop gets changed, so that the test is going to change.
好,第二个问题:,换种更好的方式来说吧,你们通常喜欢的,方式是,这个测试涉及到一个变量名字,变量在循环外已经被初始化,然后循环内部会改变这个变量的值,因此测试结果会改变。
应用推荐