Namespace myapp #Import "<std>" Using std.collections Using std.stringio Function Main() Local stk:=New Stack<String> stk.Push("Hallo world") stk.Push("Another line") For Local s:String=Eachin stk Print s Next Print "Capacity : "+stk.Capacity Print "Size : "+stk.Length stk.Compact() Print "Capacity : "+stk.Capacity Print "Size : "+stk.Length Print "Item # 1 : "+stk.Get(1) ' counting from 0... print "Item # 4 : "+stk.Get(4) ' get an error ... of course! 'change an item in the stack stk.Set(0,"Good Morning!") Print stk.Get(0) 'now print Good Morning! instead of Hallo World End
Just to learn something new (Capacity, Length and Compact() etc !
Stacks are much better than simple arrays: everything you need when you are using an array, without the problems of the array! (I really miss this feature in BlitzMax !)
Basic example, but needed for knowing better Monkey2!