Peek: Variant;
The Peek method gets value of the element placed to the stack as the last one.
After extracting, the element is not removed from a stack.
Sub UserProc;
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 UserProc;
After executing the example a stack of random elements is created, and the "v" variable contains value of the element that was placed to the stack as the last one.
See also: