本文介绍了不可变收藏品的真正优势是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
Scala提供不可变的集合,例如 Set
,列表
,地图
。我明白不可变性在并发程序中有优势。然而,在常规数据处理中,不变性的优点是什么?
如果枚举子集
,<$例如,c $ c>排列和组合
解决方案
一般来说,不可变对象更容易/更简单。 >
Scala provides immutable collections, such as Set
, List
, Map
. I understand that the immutability has advantages in concurrent programs. However what are exactly the advantages of the immutability in regular data processing?
What if I enumerate subsets
, permutations
and combinations
for example? Does the immutable collections have any advantage here?
解决方案
Generally speaking, immutable objects are easier/simpler to reason about.
这篇关于不可变收藏品的真正优势是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!