www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - array reinitialization

reply "seany" <seany uni-bonn.de> writes:
Say I defined an array as int[] a = [1,2,3,4];
Now if I do a = function(a);

will that make a to equal [1,2,3,4,5]

the function is defined as:

int[] function(int[] b)
{ return b ~ 5;}
Nov 19 2013
parent "bearophile" <bearophileHUGS lycos.com> writes:
seany:

 Say I defined an array as int[] a = [1,2,3,4];
 Now if I do a = function(a);

 will that make a to equal [1,2,3,4,5]

 the function is defined as:

 int[] function(int[] b)
 { return b ~ 5;}
D dynamic arrays are partially values, so use: int[] function(ref int[] b) Bye, bearophile
Nov 19 2013