you're welcome :smile:
# announcements
e
you're welcome 😄
s
evanchooly: cool! what if I need those objects to be assigned in some variable. mostly like s1..s5
d
That's the part that won't work. You cannot have variable names assigned by expression. You then need a data structure.
Such as a list or map.
e
forEach
and reflection or if they are in array then just reference by index
e
yeah. just use the index.
👍 2
s
got it.. thanks @evanchooly @Eugen Martynov @diesieben07
r
You could a destructuring assignment from the list to cut down on lines some more, but you'll have to consider if that's actually more readable:
Copy code
val (s1, s2, s3, s4, s5) = listOf(1, 2, 3, 4, 5).map { Node("q$it") }
👍 2