Adding Arrays
BlitzMax Forums/BlitzMax Beginners Area/Adding Arrays
| ||
I never tried to add arrays before, assuming it would just give a syntax error. Strangely, it does not. Not that it seems to do anything at all.SuperStrict Local x:Int[] = [1,2] Local y:Int[] = [2,-1] x:+y '??? Print x[0]+","+x[1] 'Prints "1,2" Should this syntax do anything, or was my initial guess correct? I find it weird it's not a syntax error, if I'm not supposed to do that. |
| ||
There is no reason this should not work. x[0] refers to an integer, same for x[1] and both is automatically converted to strings. |
| ||
You might possibly be adding the Int Pointer of the Y array to the Int Pointer of the X array? |
| ||
Aren't you just concatenating arrays x and y? I.e. you should end up with x[] having 4 elements [1,2,2,-1] after the line x:+y. Test Code SuperStrict Local x:Int[] = [1,2] Local y:Int[] = [2,-1] x:+y '??? For Local i% = 0 Until x.length Print "x[" + i + "]: " + x[i] NextBlitzMax Output on Windows Linking:untitled1.debug.exe Executing:untitled1.debug.exe x[0]: 1 x[1]: 2 x[2]: 2 x[3]: -1Array concatenation was added in BlitzMax v1.26 (see Versions.doc in the BlitzMax installation directory). |
| ||
thats not what he did up there. Sure it would concatenate but he just outputed the content of the fields. |
| ||
I think he expected that y[0] would be added to x[0] and so on. |
| ||
Thanks for clarifying. I indeed thought it would either add the fields one by one or do nothing. Should have guessed it would concatenate, or at least I should have tried. |