Bug or not?
BlitzMax Forums/BlitzMax Programming/Bug or not?
| ||
Is this a bug, or are resizable multidimensional arrays not supported?:Type TFoo EndType Local a:TFoo[] a=New TFoo[2] Assert a Local b:TFoo[,] b=New TFoo[2,2] Assert b'b equals Null |
| ||
Weird, I reinstalled 1.43b built all mods, and now it works fine. |
| ||
Can you resize (using splicing) and keep original data? |
| ||
You can re-size the array and add a spliced array to end in one line using for example ArrayA :+ ArrayB[ 5..10 ] But I don't think you can splice into the middle of an existing array without writing it yourself. I stand to be corrected as it would come in very handy. One thing I did notice is that you can index beyond the arrays length with the spliced array. Say for example in the above, that ArrayB was at some stage defined as ArrayB[ 4 ], then the above will still work but append the extra elements with Null or Zeros. |
| ||
Thank you. I meant, can you splice multidimensional arrays? |
| ||
Thank you. I meant, can you splice multidimensional arrays? Sounds impossible, considering the multidimensional arrays memory layout. Unless you use arrays of arrays, of course. |
| ||
it can actually be done. I have done it before. Its as simple as creating a new array and moving the data which is actually what slicing does. the only downside is the more dimensions and the larger the size, the process becomes exponentially slow and the harder it is to create source to manage it. Last edited 2011 |