Created
June 17, 2021 03:56
-
-
Save CheolhoJeon/080032a7e81eb0fe489b94b79d718154 to your computer and use it in GitHub Desktop.
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
package chap5.CompanionObjects | |
import atomictest.eq | |
class CompanionObjectFunction { | |
companion object { | |
private var n: Int = 0 | |
fun increment() = ++n | |
} | |
} | |
fun main() { | |
CompanionObjectFunction.increment() eq 1 | |
CompanionObjectFunction.increment() eq 2 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment