Created
May 26, 2019 18:09
-
-
Save boudhayan/236dc322efaf07842aa743969ff32f5f to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| struct Employee { | |
| let name: String | |
| private var _employer: Company | |
| var employer: Company { | |
| mutating get { | |
| if !isKnownUniquelyReferenced(&_employer) { | |
| _employer = _employer.copy() as! Company | |
| } | |
| return _employer | |
| } | |
| set { | |
| _employer = newValue | |
| } | |
| } | |
| init(name: String, employer: Company = Company()) { | |
| self.name = name | |
| self._employer = employer | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment