RosettaCodeData/Task/Enforced-immutability/SuperCollider/enforced-immutability.supercollider

6 lines
180 B
Text
Raw Permalink Normal View History

2017-09-23 10:01:46 +02:00
// 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.")