Given this source list: and this function: As expected, I get: But if I call the variable source_list outside of the function I still get: ...
Given this source list: and this function: As expected, I get: But if I call the variable source_list outside of the function I still get: ...
so, if I have for example a struct PlayerData that has members of Vector3 structs defined in System.Numerics (not readonly structs) and I pass them ...
I want to make a defensive copy of a collection passed into a method using Guava's immutable types, e.g. an ImmutableList. I must also be able to deal ...
I am wondering about how one could do something as follows in Common Lisp. Suppose I have an object (entity) in memory that is unique at a certain tim ...
Currently I have this code: I'm trying to rewrite it (just on paper) so that it makes/adds defensive copies of students rather than directly adding ...
I have the following code: My question is wheter the defensive copyOf() here is necessary, as the get() returns an immutable list anyway? Note I a ...
I've got the following class: I have another class that will take folderagent as a parameter in the constructor, is this the correct way of creatin ...
From time to time during code reviews I see constructors like that one: Is this proper way of protecting internal state of the class? If not, what' ...
Recently in an interview for Java Developer role, I was asked how do I make Class A immutable if it has a member variable, which is an object of Class ...
I m trying to change my codes in my application with using Sonar. How to fix it and why? Thanks. ...
Is there more that could be done to make this class immutable? String is already immutable, the set is returned unmodifiable. The tutees and name va ...
So I'm writing a Panel Object API for a website I'm testing with Selenium, and since this one is likely to be used by many people outside of my contro ...
Is making a defensive copy of the fileName argument necessary in this example? In theory, another thread can modify the fileName before the loadPa ...
This is an example of defensive copy in Effective java. Assume that scenario's in my underlying questions need a defensive copy, and cannot do with a ...
One should not expose the reference to a non final field if one wants to construct an immutable class - but even for immutable objects like Strings ? ...
Coming from a Java background, I'm having trouble figuring out ways to program defensively in Objective-C. Assuming SomeClass is mutable and provides ...
I did not find a direct answer to this specific question, so... Assume class: I just want a copy without caring about exact implementation of the s ...
I have a query regarding creating a Immutable class. Following are the points which I take in consideration: Make the class final Make all memb ...
Been trying to find the best way to implement a method that makes a defensive copy of a Calendar object. eg: I am particularly concerned about ...
This is an example I have seen in the Effective C# book: The author says this will work for value type and not for reference type. I couldn't under ...