nonmutating
Nonmutating describes an operation that does not modify the state of the object it is invoked on, often referred to as the receiver. In programming, distinguishing mutating from nonmutating behavior helps programmers reason about side effects, concurrency, and value semantics. A nonmutating method or function should leave the receiver unchanged, even if it performs computations, reads data, or alters other objects.
In the Swift programming language, nonmutating is used as an attribute related to protocol requirements and
Nonmutating behavior is central to emphasis on immutability in functional and value-oriented programming styles. It enables
Across languages, related concepts appear under different terms. C++ uses const member functions to promise no