digitalmars.D.learn - Multidimensional Box arrays
- Myron Alexander (10/10) Feb 02 2007 Hello.
- Myron Alexander (16/16) Feb 02 2007 Hello.
Hello. How does one create multidimensional Box arrays? I'm looking to be able to do this: Box[] a = boxArray(25, "Hello World", 1337); Box[] b = boxArray("X", "Y", 42); Box[][] ab = [a,b]; Then: unbox!(int)(ab[0][0]) Thanks, Myron.
Feb 02 2007
Hello. I seem to have solved my problem. I'm not sure what I am doing differently but it seems to work now :) ---------- import std.stdio; import std.boxer; void main() { writefln ("Boxing day"); Box[] a = boxArray(25, "Hello World", 1337); Box[] b = boxArray("X", "Y", 42); Box[][] ab = [a,b]; writefln ("%d, %s, %d", unbox!(int)(ab[0][0]), unbox!(char[])(ab[0][1]), unbox!(int)(ab[0][2])); writefln ("%s, %s, %d", unbox!(char[])(ab[1][0]), unbox!(char[])(ab[1][1]), unbox!(int)(ab[1][2])); } ---------- Regards, Myron
Feb 02 2007