https://kotlinlang.org logo
Title
m

mp

01/24/2019, 12:04 PM
hi there Im trying to understand why this
var externalId: String = ""
code provide to me this kind of object wrapping. but when I`m trying to set this value in
data class Id(var externalId: String)
it actually tooks 16332. And I “miss” my reference I can’t understand why this ref$ObjectRef appears Advice pls some documentation page about this
t

tateisu

01/24/2019, 12:14 PM
is that propertie? local variable that modified by lambda?
a

arve

01/24/2019, 12:20 PM
@mp Did you mean
val
instead of
var
?
m

mp

01/24/2019, 12:22 PM
@tateisu yeap - wanna implement postponed update from lambda and yes - its variable defined in other lambda as local var
@arve as I can see - there is no big difference in val or var
a

arve

01/24/2019, 12:24 PM
Could you share some more code context? I don't quite understand exactly what you're trying to do 🙂
t

tateisu

01/24/2019, 12:26 PM
that lambda have to access "reference of string" to modifiy it, then kotlin make its local var to object reference.
debugger shows its representation on JVM, it may not equals to as defined by you.
simple local var that is used only in its scope, it's representation on JVM is register. it can't be accessed from outside of the method. if access is required by such as lambda, inner function,etc, kotlin make reference representation of local var and pass it to lambda,inner function,etc those have representation as another jvm method.
m

mp

01/24/2019, 12:53 PM
@arve @tateisu probably this will give a bit more understanding what I`m trying to do but still code is not very representable
but as I understand @tateisu gave related explanation already
👍 1
😎 1
@tateisu but its only read access ?! because when I`m trying to store that reference it comes unwrapped and I can’t modify it from lambda that I`ve showed before
seems that I`m trying to implement very bad practice thing
t

tateisu

01/24/2019, 1:38 PM
subUrl is property, caller pass the class object instance to lambda, no need to create reference variable.
simple local var that is used only in its scope, it's representation on JVM is register. it can't be accessed from outside of the method. but object property has different situation.
m

mp

01/24/2019, 1:39 PM
I have cases when I will resolve suburl later (inside lambda)
t

tateisu

01/24/2019, 1:40 PM
subUrl is property, caller pass the class object instance to lambda, no need to create reference variable.
"Tools > Kotlin > Show Kotlin Bytecode" to check what bytecode is generated.
m

mp

01/24/2019, 1:55 PM
@tateisu I`m trying to change this subUrl later in lambda - much later when specific instance of TestCases created
here will be created 2 test cases and I though that I’ll have ability to change suburl of second one with editing of externalId that I`ve allocate above
t

tateisu

01/24/2019, 2:13 PM
I do not know what you want to avoid. I think that it should be used as it is
ObjectReference is jvm representation. still it is string in kotlin syntax.
m

mp

01/24/2019, 2:18 PM
its ok… I don’t now also! 😃 😃 😃 still tnx