这里还有人吗?Elixir的list 和 tuple

作者 vivianandliliqin 所属板块 问答
when you update a tuple, all entries are shared between the old and the new tuple, except for the entry that has been replaced. In other words, tuples and lists in Elixir are capable of sharing their contents. This reduces the amount of memory allocation the language needs to perform and is only possible thanks to the immutable semantics of the language. 来源https://elixir-lang.org/getting-started/basic-types.html 这句话怎么理解比较好,这个教程里前面说 updating or adding elements to tuples is expensive because it requires creating a new tuple in memory。上面又是all entries are shared between the old and the new tuple 既然entries是共享的 所以新tuple是引用了旧tuple的entries?
0 回复