Notifications
Clear all

[Closed] "Pointer" to an array/variable?

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
(@serejah)
Joined: 1 year ago

Posts: 0

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.

if I’’m not mistaken this should print 42

(
a = #(1,2,3)
ref = &a
a = #(42)
format "%\n" (*ref)
)

This way it does work. Thank you