Peek: Variant;
The Peek method extracts value of the element placed to the stack as the last one. After extracting, the element is not removed from a stack.
Sub Main;
Var
Stack1: IStack;
i: Integer;
v: Variant;
Begin
Stack1:=New Stack.Create;
For i:=0 To Math.RandBetweenI(50,100) Do
Stack1.Push("Value "+Math.RandBetweenI(0,100).ToString);
End For;
v:=Stack1.Peek;
End Sub Main;
After executing the example a stack of random elements is created, and the "v" variable contains value of the element that was placed to a stack as the last one.
See also: