Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Immutability | High performance with idiomatic Kotlin
interface ValueHolder<V> {
val value: V
class IntHolder : ValueHolder<Int> {
override val value: Int
get() = Random().nextInt()
fun main() {
val sample = IntHolder()
println(sample.value) //260078462
println(sample.value) //1657381068
// immutability by default
data class ImmutableKey(val name: String? = null)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment