Notifications
Clear all
[Closed] "Pointer" to an array/variable?
Jan 15, 2023 2:38 am
Is it possible to create a variable, which will always “holds” the most recent value of an array or another variable?
(
ar1 = #(1,2,3)
ar2 = #(4,5,6)
ar3 = #(7,8,9)
-- what magic must happen here?
pt = ar2
format "pt: %\n" pt
format "ar2: %\n" ar2
ar2 = #(444,555,666)
-- pt must hold #(444,555,666) not #(4,5,6)
format "pt: %\n" pt
format "ar2: %\n" ar2
)
4 Replies
1 Reply
Jan 15, 2023 2:38 am
Thank you.
Can’t make it to work.
-- Compile error: & references only allowed on variables, properties and array indexes
It seems that an array can’t be referenced.
Jan 15, 2023 2:38 am
if I’’m not mistaken this should print 42
(
a = #(1,2,3)
ref = &a
a = #(42)
format "%\n" (*ref)
)