There's no doubt that the restriction to only capturing immutable state from the lexical context is quite irritating to programmers.
毫无疑问,仅从词法上下文捕获不变的状态这一限制,令程序员非常不满意。
This pattern requires that the value being published be effectively immutable — that its state not change after publication.
这个模式要求被发布的值是有效不可变的——即值的状态在发布后不会更改。
If you have an immutable object, you must set whatever state it will contain in the constructor.
如果您有一个不可变对象,则必须要在构造函数中设置该对象将包含的任何状态。
应用推荐