O'Reilly logo

Swift Functional Programming - Second Edition by Dr. Fatih Nayebi

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Behaviour

Value types do not behave. A value type stores data and provides methods to use its data. A value type can only have a single owner and it does not have deinitializers as there are no references involved. Some of the value type methods may cause the value type to mutate itself, but control flow is rigidly controlled by the single owner of the instance. As the code will only execute when directly invoked by a single owner and not from many sources, it is easy to reason about the value type code execution flow.

On the other hand, a reference type might subscribe itself as a target of other systems. It might receive notifications from other systems. These sorts of interactions require reference types as they can have multiple owners. ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required