Hi,
I have a question about the compiled bytecode. What happen with val properties?
class Foo (val arg1: Int, val arg2: String) { ... }
Do you make of them final attributes or private attributes with one getter method?
Hi,
I have a question about the compiled bytecode. What happen with val properties?
class Foo (val arg1: Int, val arg2: String) { ... }
Do you make of them final attributes or private attributes with one getter method?
Kotlin is uses final
by default, so everything that isn’t marked as open
uses final
in the bytecode.
Properties are a bit more complicated. I think private
properties are just compiled to a field. Anything else get’s compiled into a getter-function(val
and var
) as well as a setter-function for var
. If the property requires it kotlin automatically adds a private
backing field.
Thank you