Restart the Inheritance

#inherittance

Overview

Below example shows how to restart the inheritance

Version 1
class Ewok {
    var fluffinessPercentage = 100
}
var chirpa = Ewok()
var wicket = Ewok()
chirpa.fluffinessPercentage = 90
print(wicket.fluffinessPercentage) // print: 100
print(chirpa.fluffinessPercentage) // print: 90
Version 2
class Ewok {
    var fluffinessPercentage = 100
}
var chirpa = Ewok()
var wicket = chirpa
chirpa.fluffinessPercentage = 90
print(wicket.fluffinessPercentage) // print: 90
print(chirpa.fluffinessPercentage) // print: 90

Sample Codes

Sources

Videos

Articles / Documents

Last updated