Created
June 9, 2023 22:55
-
-
Save monkey-codes/ccd5bf747e8e0b0b8e9c68bb1f299985 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
| val x = StringBuilder("hello") | |
| val y = x.append(" world") | |
| val r1 = y.toString() //hello world | |
| val r2 = y.toString() //hello world | |
| //Now if we substitute 'y' with the expression that created it 'x.append(" world")': | |
| val r1 = x.append(" world").toString() //hello world | |
| val r2 = x.append(" world").toString() //hello world world | |
| r1 != r2 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment