Delete topic please

I know that sig variable can be re-used and the processing is serial .
Each new sig processes the sig of the previous line

(
{
	var sig,sig2;
	sig=Saw.ar([110,112])*0.5;
	sig=sig+Pulse.ar([55,57])*0.5;
	sig2=EnvGen.ar(Env([0.2,1,0.01],[5.0,10.500],[10,-5]),doneAction:2);
	sig2=sig2*5000;
	sig=LPF18.ar(sig,sig2,0.2,0.5);
	sig*0.5
	
}.
play)

Easy and convenient

But when doing this like
a=15
a+1
a*2

the console gives a=15 for the first line
the second gives us 16
and te third line retuns 30 , why not 32 ?
Why is it different from the real time audio example using sig ?

Please delete topic , I forgot

a=15
a=a+1
a=a*2

because 15*2 is 30. aā€™s value didnā€™t change after the expression a+1. if you want to change the value of a you need to assign to it. a = a + 1

Thatā€™s why I want the topic to be deleted , I already found out myself

Thereā€™s an interesting topic here about the difference between operations that return a new (or different) object as their result, and those that mutate the state of the same object.

Math operators always return new objects (no mutation).

But aList.add(aValue) always mutates the List object, and the effect of that would be seen in future operations (even without reassignment).

(And then thereā€™s the ā€œleakā€ of the implementation detail that anArray.add(something) may return the same object or a new object :laughing: so to be safe, itā€™s better to reassign always ā€“ this is noted in the Array help file.)

hjh

@gentleclockdivider are you not able to withdraw the post yourself? i thought this was a Discourse feature available to everyone. if not i can delete the topic for you.

i would suggest to rename the title and keep this post. itā€™s interesting and instructive to beginners.

also, isnā€™t there a alias for a = a + b, I think Processing has something like a =+ b to add to original value in one ā€˜stepā€™?

1 Like

Not in SC, Iā€™m afraid.

hjh