Noob Array and Const problem
BlitzMax Forums/BlitzMax Beginners Area/Noob Array and Const problem
| ||
Why is [0.0] not a const? (or [0.0,0.0,0.0]) |
| ||
Eh?? |
| ||
I think I'm missing something but here goes... '[' is an invalid variable character? but I am guessing you actually typed something different in your code. |
| ||
Const GF:Float[] = [0.0,0.0,0.0] or Function Create:TV(PArray:Float[] = [0.0,0.0,0.0] )For example Or anytime I wanted to allocate a constant. Sorry, maybe I was a bit "Unspecific" in the first post. Why is it that if I try to allocate [0.0] (Or [0.0,0.0,0.0] for example) to a constant. The compiler tells me that [0.0] isnt a constant So any ideas why [0.0] isnt a constant? |
| ||
I'm not fully sure but I think the problem is not the [0.0] but the fact that an array can't be constant as it is dynamically allocated in runtime. |
| ||
Any ideas then how to have a default array in the params. Because as far as Im aware if I dont give a default, then I do need to pass an arrary every time. ie bob:Type = Type.Create(anArray) Fred:Type = Type.Create |
| ||
the only default you can give is =null (as with types in general) |
| ||
Test([1, 2, 3, 4, 5]) Print Test() End Function Test(array[]=Null) If array = Null Then array = [10, 20, 30] For Local a = EachIn array Print a Next End Function ?? |
| ||
I knew it would be something obvious that would make me look stupid Thanks |