Hi, having trouble getting 2D arrays working properly.
Something like this causes errors
int32[][] test = { { 1,1,1 }, {2,2,2} };
And something like this, I can’t figure out how to properly initialize
TArray<TArray<int32>> test;
Also, the 2D array holds a HUGE amount of data.
How can I properly create a 2D array, initialized with a large amount of data? (Without needed a thousand test.Add()) The first example would be great since the data can just be added with commas, but unreal doesn’t like int32[][], so I can’t figure out the proper way to do it.
The first problem is that your braces are in the wrong place:
int32 test[][] = { {1, 2, 3}, {4, 5, 6} };
The second is that you need to specify the number of elements in each sub-array:
int32 test[][3] = { {1, 2, 3}, {4, 5, 6} };
I hope that helps.
I’d question why you want a “huge” amount of data to be compiled into the program binary and take up static memory space. You might want to consider using a Data Table:
Whoops, braces was just a typo when I wrote em here. Didn’t know I needed to specify the sub-array size though, thanks!
The data is actually a few decently sized 2D arrays from a Simplex Noise library that I’m porting over from c++. It’s just a list of raw pseudo-random numbers to help with the generation I suppose. The c++ version had it working with just int32 test[][], glad to know it’s an easy fix!