Const Array in Class do not work
Monkey Forums/Monkey Bug Reports/Const Array in Class do not work
| ||
It is not possible to create a const int array like this: Const test:Int[] = [1,2,3] this work: Global test:Int[] = [1,2,3] Strict Import mojo Class App2 Extends App Const test:Int[] = [1,2,3] '<<<<<<<<<<<< Method OnCreate:Int () SetUpdateRate(60) Print(test[0]) Return 0 End Method OnUpdate:Int () Return 0 End Method OnRender:Int () Cls(0,0,0) Return 0 End End Function Main:Int () New App2() Return 0 End |
| ||
a constant usually is replaced by its value at compile time. I would be surprised if this should work and it is a bug. |
| ||
outside simple test[1] you mean that monkey can not detect test[1+x] and replace it, because x is unknown at compile time this make sense, but monkey can internally use global instead and protect array read only at compile time |
| ||
Why don't you use a global instead and in the first place. Never heard about constant arrays before. |
| ||
you can use a readonly property to expose a private array contents and it should do it. |