Skip to content

Instantly share code, notes, and snippets.

@CheolhoJeon
Created June 17, 2021 04:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save CheolhoJeon/38f05f33d7328a9482a072d45856c715 to your computer and use it in GitHub Desktop.
Save CheolhoJeon/38f05f33d7328a9482a072d45856c715 to your computer and use it in GitHub Desktop.
package chap5.CompanionObjects
import atomictest.eq
class Counted {
companion object {
private var count = 0
}
private val id = count++
override fun toString() = "#$id"
}
fun main() {
List(4) { Counted() } eq "[#0, #1, #2, #3]"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment