All Questions

1447
votes
16answers
851688 views

How to clone or copy a list?

What are the options to clone or copy a list in Python? Using new_list = my_list then modifies new_list every time my_list changes. Why is this?
4161
votes
55answers
1462567 views

What is the most efficient way to deep clone an object in JavaScript?

What is the most efficient way to clone a JavaScript object? I've seen obj = eval(uneval(o)); being used, but that's non-standard and only supported by Firefox. I've done things like obj = JSON.parse(...
1687
votes
37answers
646383 views

Deep cloning objects

I want to do something like: MyObject myObj = GetMyObj(); // Create and fill a new object MyObject newObj = myObj.Clone(); And then make changes to the new object that are not reflected in the orig...
438
votes
11answers
308866 views

How do you do a deep copy of an object in .NET (C# specifically)?

I want a true deep copy. In Java, this was easy, but how do you do it in C#?
591
votes
20answers
832983 views

How do I copy an object in Java?

Consider the code below: DummyBean dum = new DummyBean(); dum.setDummy("foo"); System.out.println(dum.getDummy()); // prints 'foo' DummyBean dumtwo = dum; System.out.println(dumtwo.getDummy()); // p...
203
votes
17answers
338258 views

How to clone ArrayList and also clone its contents?

How can I clone an ArrayList and also clone its items in Java? For example I have: ArrayList<Dog> dogs = getDogs(); ArrayList<Dog> clonedList = ....something to do with dogs.... And I ...
222
votes
17answers
243628 views

How do you make a deep copy of an object in Java?

In java it's a bit difficult to implement a deep object copy function. What steps you take to ensure the original object and the cloned one share no reference?
159
votes
8answers
112306 views

Java: recommended solution for deep cloning/copying an instance

I'm wondering if there is a recommended way of doing deep clone/copy of instance in java. I have 3 solutions in mind, but I can have miss some, and I'd like to have your opinion edit: include Bohzo...
138
votes
11answers
93984 views

How can I change the default behavior of console.log in Safari?

In Safari with no add-ons, console.log will show the object at the last state of execution, not at the state when console.log was called. I have to clone the object just to output it via console.log ...
438
votes
22answers
432744 views

How do I clone a generic list in C#?

I have a generic list of objects in C#, and wish to clone the list. The items within the list are cloneable, but there doesn't seem to be an option to do list.Clone(). Is there an easy way around thi...

Previous Next