digitalmars.D.learn - Copying int[] from dynamic to static arrays?
- AEon (14/14) Mar 29 2005 I have a global static array called
- Derek Parnell (9/31) Mar 29 2005 The syntax to use in this case is ...
I have a global static array called int[6] UTtime; and a function that returns a dynamic array (also with 6 elements): int[] dt = convert_Dtime_to_Digits( myTimeUT ); but: UTtime = convert_Dtime_to_Digits( myTimeUT ); will not compile, since there is a conflict between the static and dynamic arrays, even though they have the same size. That is to be expected. So is the below: foreach( int i, int datetime; UTtime ) UTtime[i] = datetime; the only way to copy the data? Or is there some other D shortcut to copy the data between arrays? AEon
Mar 29 2005
On Wed, 30 Mar 2005 04:32:14 +0200, AEon wrote:I have a global static array called int[6] UTtime; and a function that returns a dynamic array (also with 6 elements): int[] dt = convert_Dtime_to_Digits( myTimeUT ); but: UTtime = convert_Dtime_to_Digits( myTimeUT ); will not compile, since there is a conflict between the static and dynamic arrays, even though they have the same size. That is to be expected. So is the below: foreach( int i, int datetime; UTtime ) UTtime[i] = datetime; the only way to copy the data? Or is there some other D shortcut to copy the data between arrays?The syntax to use in this case is ... UTtime[] = convert_Dtime_to_Digits( myTimeUT ); But the function *must* return exactly the same length as the fixed array length. -- Derek Melbourne, Australia 30/03/2005 12:43:10 PM
Mar 29 2005