RosettaCodeData/Task/Enforced-immutability/SuperCollider/enforced-immutability.sc
2023-07-01 13:44:08 -04:00

5 lines
180 B
Python

// you can freeze any object.
b = [1, 2, 3];
b[1] = 100; // returns [1, 100, 3]
b.freeze; // make b immutable
b[1] = 2; // throws an error ("Attempted write to immutable object.")