digitalmars.D.learn - correct way to set a dynamic 2d array?
- clayasaurus <clayasaurus gmail.com> May 30 2005
- Derek Parnell <derek psych.ward> May 30 2005
- Hasan Aljudy <hasan.aljudy gmail.com> May 30 2005
- Derek Parnell <derek psych.ward> May 30 2005
- "Jarrett Billingsley" <kb3ctd2 yahoo.com> May 31 2005
- Stewart Gordon <smjg_1998 yahoo.com> Jun 02 2005
is this the correct way to set a dynamic 2D array?
int[][] dynamic;
dynamic.length = width;
for (int i = 0; i < dynamic.length; i++)
dynamic[i].length = height;
Just seems a bit weird.
May 30 2005
On Tue, 31 May 2005 03:56:00 +0000, clayasaurus wrote:is this the correct way to set a dynamic 2D array? int[][] dynamic; dynamic.length = width; for (int i = 0; i < dynamic.length; i++) dynamic[i].length = height; Just seems a bit weird.
Currently, yes. Though it could also be written as ... int[][] dynamic; dynamic.length = width; foreach (inout int[] x; dynamic) x.length = height; -- Derek Melbourne, Australia 31/05/2005 2:33:02 PM
May 30 2005
Derek Parnell wrote:On Tue, 31 May 2005 03:56:00 +0000, clayasaurus wrote:is this the correct way to set a dynamic 2D array? int[][] dynamic; dynamic.length = width; for (int i = 0; i < dynamic.length; i++) dynamic[i].length = height; Just seems a bit weird.
Currently, yes. Though it could also be written as ... int[][] dynamic; dynamic.length = width; foreach (inout int[] x; dynamic) x.length = height;
can't you just say this? dynamic[].length = height;
May 30 2005
On Tue, 31 May 2005 00:31:47 -0600, Hasan Aljudy wrote:Derek Parnell wrote:On Tue, 31 May 2005 03:56:00 +0000, clayasaurus wrote:is this the correct way to set a dynamic 2D array? int[][] dynamic; dynamic.length = width; for (int i = 0; i < dynamic.length; i++) dynamic[i].length = height; Just seems a bit weird.
Currently, yes. Though it could also be written as ... int[][] dynamic; dynamic.length = width; foreach (inout int[] x; dynamic) x.length = height;
can't you just say this? dynamic[].length = height;
No. You get this message ... slice expression dynamic[] is not a modifiable lvalue -- Derek Melbourne, Australia 31/05/2005 4:46:02 PM
May 30 2005
"Derek Parnell" <derek psych.ward> wrote in message news:k3gx4tkutm62$.wl0ydvkulqru.dlg 40tude.net...can't you just say this? dynamic[].length = height;
No. You get this message ... slice expression dynamic[] is not a modifiable lvalue
Isn't this something that would be possible with array vectorization? I'd really love this syntax..
May 31 2005
Jarrett Billingsley wrote:"Derek Parnell" <derek psych.ward> wrote in message news:k3gx4tkutm62$.wl0ydvkulqru.dlg 40tude.net...can't you just say this? dynamic[].length = height;
I'd really love this syntax..
But it would create confusion.. digitalmars.D.bugs/1942 Stewart. -- My e-mail is valid but not my primary mailbox. Please keep replies on the 'group where everyone may benefit.
Jun 02 2005








Stewart Gordon <smjg_1998 yahoo.com>