Created
May 24, 2023 14:11
-
-
Save enshahar/75f11a4fc68411ecd240a60fc27e3b6a to your computer and use it in GitHub Desktop.
private 멤버나 constructor는 공변성 검증 대상이 아님
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
class Box<out T, FUN: ()->T>(v: T, private val nextval: FUN) { | |
private var value: T = v | |
private fun log(v: T) { | |
println(v) | |
} | |
fun logPublic(v: T) { // Type parameter T is declared as 'out' but occurs in 'in' position in type T | |
println(v) | |
} | |
fun get():T { | |
value = nextval() | |
log(value) | |
logPublic(value) | |
return value | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment