Best of JVM — July 2024
- 1
- 2
ProAndroidDev·2y
Kotlin reified Explained (no more type erasure)
Kotlin solves the problem of type erasure at runtime by introducing the 'reified' keyword, which preserves type information. This keyword works in conjunction with inline functions, allowing code to be moved to the call site and maintaining type information. This approach enables writing more generic and readable algorithms.
- 3
droidcon·2y
Internal Mechanism of val in Kotlin
Kotlin's `val` keyword is used to declare immutable variables, ensuring they can only be assigned once. This immutability is enforced through the compilation of Kotlin code into Java bytecode, where `val` variables are marked with the Java `final` modifier. The use of `val` enhances thread safety, code clarity, and performance, particularly in concurrent programming.