Variables as function arguments

Hi!
I need to have a function receive a variable definition instead of the value of the variable at evaluation.

~thing = 2;

(
~testFunc = { |input|
Routine({
	while(
		{t.isRunning},
		{
			input.postln;
			0.4.wait;
	})
}).play;
};
)

~testFunc.value(~thing);

Now if i change the content of ~thing while the Routine is running it keeps spitting out the first supplied value.

I feel like there would be a simple method for this but I’ve gone through the docs and found nothing.

You could send it a function that you evaluate instead of a value:


(
~testFunc = { |input|
Routine({
		{

			input.value.postln;
			0.4.wait;
		}.loop
}).play;
};
)

~testFunc.value({~thing});
1 Like

Oh wow of course. Thank you!