Created
May 11, 2025 10:21
-
-
Save VovaStelmashchuk/8e012f02a8b650c7e9e17d876c000b28 to your computer and use it in GitHub Desktop.
Although the scope functions are a way of making the code more concise, avoid overusing them: it can decrease your code readability and lead to errors. Avoid nesting scope functions and be careful when chaining them: it's easy to get confused about the current context object and the value of this or it.
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
// Try to figure out, what changed, without knowing the details | |
fun makeConnection(first: User, second: User) { | |
first.apply { | |
second.apply { | |
b = a | |
c = b | |
} | |
} | |
} | |
fun makeConnection(first: User, second: User) { | |
first.b = this.a | |
second.c = first.b | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment