Re: .dup vs operation on all elements

2018-12-03 Thread Goksan via Digitalmars-d-learn
On Monday, 3 December 2018 at 22:04:25 UTC, Neia Neutuladh wrote: On Mon, 03 Dec 2018 21:27:52 +, faissaloo wrote: Then shouldn't the following output false, false, true? An object reference is a pointer value. The pointer values are copied. The pointed-at objects are not copied. Furthe

Re: .dup vs operation on all elements

2018-12-03 Thread Neia Neutuladh via Digitalmars-d-learn
On Mon, 03 Dec 2018 21:27:52 +, faissaloo wrote: > Then shouldn't the following output false, false, true? An object reference is a pointer value. The pointer values are copied. The pointed-at objects are not copied. Furthermore, the syntax Object[6] array = new Object(); only allocate

Re: .dup vs operation on all elements

2018-12-03 Thread faissaloo via Digitalmars-d-learn
On Monday, 3 December 2018 at 20:37:22 UTC, Jonathan M Davis wrote: On Monday, December 3, 2018 1:07:24 PM MST Goksan via Digitalmars-d-learn wrote: Are there any differences between these 2 methods of copying elements? double[] array = [ 1, 20, 2, 30, 7, 11 ]; // Non dup double[6] bracket_sy

Re: .dup vs operation on all elements

2018-12-03 Thread Jonathan M Davis via Digitalmars-d-learn
On Monday, December 3, 2018 1:07:24 PM MST Goksan via Digitalmars-d-learn wrote: > Are there any differences between these 2 methods of copying > elements? > > double[] array = [ 1, 20, 2, 30, 7, 11 ]; > > // Non dup > double[6] bracket_syntax_dup = array; > bracket_syntax_dup[] = array; > bracket

Re: .dup vs operation on all elements

2018-12-03 Thread Daniel Kozak via Digitalmars-d-learn
Yes it is. The dup version just make an extra copy of array for no reason. po 3. 12. 2018 21:10 odesílatel Goksan via Digitalmars-d-learn < digitalmars-d-learn@puremagic.com> napsal: > Are there any differences between these 2 methods of copying > elements? > > double[] array = [ 1, 20, 2, 30,

.dup vs operation on all elements

2018-12-03 Thread Goksan via Digitalmars-d-learn
Are there any differences between these 2 methods of copying elements? double[] array = [ 1, 20, 2, 30, 7, 11 ]; // Non dup double[6] bracket_syntax_dup = array; bracket_syntax_dup[] = array; bracket_syntax_dup[0] = 50; // Dup double[6] normal_dup = array.dup; normal_dup[0] = 100; OUTPUT: (ar