DEV Community

Davmi Jose Valdez Ogando
Davmi Jose Valdez Ogando

Posted on

100 Days of Swift - Day 10

Continuation of Hacking With Swift 100 Days of Swift

Day 10 - Classes

Straight outta the intro we are let known the main difference between structs and classes. Classes enable inheritance in our code, and if you come from a OOP background you already know the importance of this feature.

Overriding methods is done by using the override keyword, and in order to avoid a class from being further extended you can always use the final keyword.

Another big difference is that structs are value types while classes are reference types. This means that copying the instance of a class and modifying a property results in the property value being changed on both variables, while if try the same with a struct each variable will hold a different value.

Top comments (0)