I’m trying to get my head around mutable vs immutable objects. Using mutable objects gets a lot of bad press (e.g. returning an array of strings from a method)...
I’m rebuilding an old Java project in Javascript, and realized that there’s no good way to do enums in JS. The best I can come up with is: const...
A frozen set is a frozenset. A frozen list could be a tuple. What would a frozen dict be? An immutable, hashable dict. I guess it could be something...
This question already has answers here: Why can’t strings be mutable in Java and .NET? (17 answers) Closed 9 years ago. As we all know, String is immutable. What...
This question already has answers here: Java Immutable Collections (7 answers) Closed 2 days ago. From the Collections Framework Overview: Collections that do not support modification operations (such as...
If a tuple is immutable then why can it contain mutable items? It is seemingly a contradiction that when a mutable item such as a list does get modified,...
I’m confused on what an immutable type is. I know the float object is considered to be immutable, with this type of example from my book: class RoundFloat(float): def...
This question already has answers here: Immutability of Strings in Java (26 answers) Closed 6 years ago. I wrote the following code on immutable Strings. public class ImmutableStrings {...
Although I have never needed this, it just struck me that making an immutable object in Python could be slightly tricky. You can’t just override __setattr__, because then you...
I seem to be having issues pushing data into a state array. I am trying to achieve it this way: this.setState({ myArray: this.state.myArray.push('new value') }) But I believe this...