The true definition of immutability?

后端 未结 10 1890
被撕碎了的回忆
被撕碎了的回忆 2021-02-09 03:15

I am wondering how immutability is defined? If the values aren\'t exposed as public, so can\'t be modified, then it\'s enough?

Can the values be modified inside the type

10条回答
  •  醉梦人生
    2021-02-09 03:46

    The definition of immutability can be located on Google .

    Example:

    immutable - literally, not able to change.
    www.filosofia.net/materiales/rec/glosaen.htm

    In terms of immutable data structures, the typical definition is write-once-read-many, in other words, as you say, once created, it cannot be changed.

    There are some cases which are slightly in the gray area. For instance, .NET strings are considered immutable, because they can't change, however, StringBuilder internally modifies a String object.

提交回复
热议问题