<@U2H3SABQF> ```val b get() = array[5] set...
# announcements
k
@elect
Copy code
val b
    get() = array[5]
    set(value) { array[5] = value }
and then use
::b
e
uhm, no other way?
k
Well what do you need it for?
e
I'm started to use reference to primitives in my code
k
You could write a custom delegate to simplify this if you need it often, something like
val b by arrayArraySpot(aarray, 5)
e
and since references to local variable is not yet available, I'm declaring them most of the time as top level or in the companion object
but right now, my code started to recursively call multiple functions which makes uses of these variables
to I need to create a sort of push/pop mechanismus
k
Hmm, do you have a code sample?
e
of this concept?
not really, I'm working on it right now
I'm trying now to implement your tip
k
Still don't really get what you're going for but let me know if it works 🙂.
e
in that gist
there is an
inline fun
the idea is to call that function instead a top level or companion object primitive
and that function will offer a primitive, which is not being used by any other function at the moment, and I can use its reference to pass it along
k
Ah I see, then I think delegates are indeed the solution.
Although performance might not be great.
e
you think?
what you had in mind exactly with delegates?
mind sketching up a quick example?
k
Sure, just a sec.
e
I update the gist
what you think?
k
Should work I think.
I created this over-engineered example: https://gist.github.com/b4bb3f6257eaf3ae8c6d6c2e2771dec1
e
I'll play with it, thanks dear
one last question, do you see any perf flaws with the design I proposed?
k
I think you should be fine.