In Mercury I can use:
A = B^some_field := SomeValue
须对A至B文本的约束,但<编码> > > >>> 外地代码> 是<代码>SomeValue,而不是在B中。 我认为,Haskell等同:
a = b { some_field = some_value }
Does Scala have something like this for "modifying" immutable values. The alternative seems to be to have a constructor that directly sets every field in the instance, which isn t always ideal (if there are invarients the constructor should be maintaining). Plus it would be really clunky and much more fragile if I had to explicitly pass every other value in the instance I want to have a modified copy of.
我无法找到这方面的任何东西,方法是ling,或者在语言参考手册或“Scala by Example”的简短调查中找到(我读过了开端到定点,但却吸收了全部内容,因此,情况可能确实如此)。
我可以看到,这一特点可能会与 Java式出入保护以及二等杂类(......)发生一些令人厌恶的互动。