Indexing of Stacks Allowed?

Monkey Forums/Monkey Programming/Indexing of Stacks Allowed?

DGuy(Posted 2011) [#1]
The docs say:
Stacks may also be efficiently indexed using an integer index, and elements may be inserted and removed. This allows stacks to also be used as a dynamic array (an array where the length can change), much like a C++ vector, or C# ArrayList.

But this code:
Local s:= New IntStack
s.Push( 0 )
Print s[ 0 ]

Leads to this error:
TRANS monkey compiler V1.12
Parsing...
Semanting...
/Users/DGuy/Programming/Monkey/CardGameTest/CardMgr_Test/main.monkey<58> : Error : Only strings and arrays may be indexed.

Bug or wrong syntax?


Jesse(Posted 2011) [#2]
Stack.Get(index)



DGuy(Posted 2011) [#3]
Oh well, ... I mean saw the 'Get' method but I guess it was just wishful thinking on my part ... :)