August 29, 2003 Braindead re: row-wise & column-wise | ||||
---|---|---|---|---|
| ||||
I'm getting the semantics of multidimensional arrays all messed up in my mind, and I need someone to help clarify something for me. When declaring an array of strings, you're e3ssentially declaring a multi-dimensional array. But I always get my row-wise and my column-wise array accessing messed up. So, if I declare an array like this... char[][] strings = ["zero", "one", "two", "three"]; ..and I want to get the "one" entry into a new string, which of these do I use... char[] x = strings[][1]; char[] x = strings[1][]; char[] x = strings[1]; I've been writing code exclusively in perl lately (a requirement for work (btw, I HATE perl's variable prefixes, using $ to dereference scalars from @ and % structures, not to mention the {} required to dereference a hash value)), and I'm having trouble remembering whether perl uses the same accessing order (row-wise? column-wise?) as Java or C. It's like somebody whacked me in the head with a stupid-stick. --Benji Smith |
August 30, 2003 Re: Braindead re: row-wise & column-wise | ||||
---|---|---|---|---|
| ||||
Posted in reply to Benji Smith | "Benji Smith" <dlanguage@xxagg.com> wrote in message news:binldj$1uka$1@digitaldaemon.com... > I'm getting the semantics of multidimensional arrays all messed up in my mind, > and I need someone to help clarify something for me. > > When declaring an array of strings, you're e3ssentially declaring a multi-dimensional array. But I always get my row-wise and my column-wise array > accessing messed up. So, if I declare an array like this... > > char[][] strings = ["zero", "one", "two", "three"]; > > ..and I want to get the "one" entry into a new string, which of these do I use... > > char[] x = strings[][1]; > char[] x = strings[1][]; > char[] x = strings[1]; The 3rd one. |
Copyright © 1999-2021 by the D Language Foundation