Created
June 11, 2018 22:40
-
-
Save jivimberg/3fd70a9bd69632c2275d14e24c0e7baa to your computer and use it in GitHub Desktop.
Immutable mutual assignments (https://stackoverflow.com/questions/50799240/kotlin-mutual-assignments/50802264#50802264)
This file contains 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
class Person() { | |
private lateinit var _other: Person | |
private constructor(_other: Person) : this() { | |
this._other = _other | |
} | |
val other: Person | |
get() { | |
if (!::_other.isInitialized) { | |
_other = Person(this) | |
} | |
return _other | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment