ne of the ways in which Swift helps us write more robust code is through its concept of value types, which limit the way that state can be shared across API boundaries. That’s because, when using value types, all mutations are (by default) only performed to local copies of the values that we’re working with, and APIs that actually perform mutations have to be clearly marked as
In this article, let’s explore that keyword, as well as its
nonmutatingcounterpart, and the sort of capabilities that those language features provide.
Source: Mutating and non-mutating Swift contexts, an article by John Sundell.