Thread overview | ||||||
---|---|---|---|---|---|---|
|
September 06, 2001 Spec Clarification: Initializing arrays with arrays | ||||
---|---|---|---|---|
| ||||
If we have this code: int[] first; int[] second = first; Is second initialized by reference (that is, second points into the same memory as first), or by value (a new copy is made)? |
September 07, 2001 Re: Spec Clarification: Initializing arrays with arrays | ||||
---|---|---|---|---|
| ||||
Posted in reply to Russ Lewis | By reference. To do a copy by value: second[] = first[]; Russ Lewis wrote in message <3B980434.DFCCE2A5@deming-os.org>... >If we have this code: > >int[] first; >int[] second = first; > >Is second initialized by reference (that is, second points into the same >memory as first), or by value (a new copy is made)? > |
September 07, 2001 Re: Spec Clarification: Initializing arrays with arrays | ||||
---|---|---|---|---|
| ||||
Posted in reply to Walter | Walter wrote:
> By reference. To do a copy by value:
>
> second[] = first[];
So
int[] second = first;
initializes by reference, while
int[] second = first[];
initializes by value?
|
September 07, 2001 Re: Spec Clarification: Initializing arrays with arrays | ||||
---|---|---|---|---|
| ||||
Posted in reply to Russ Lewis | Russ Lewis wrote in message <3B987832.7B8B6B19@deming-os.org>... >Walter wrote: > >> By reference. To do a copy by value: >> >> second[] = first[]; > >So > >int[] second = first; > >initializes by reference, while > >int[] second = first[]; > >initializes by value? Actually, there's no way to initialize a dynamic array by value. |
Copyright © 1999-2021 by the D Language Foundation