format
typescript
Stack.Peek()class: Stack
description
Get the element at the top of the stack without removing it.
parameter
| param_name | type | description |
|---|
reture
| type | description |
|---|---|
T|undefined | The element at the top of the stack. |
code example
typescript
let stack = new Stack<Number>();
stack.Push(1);
stack.Push(2);
stack.Push(3);
// Get the element at the top of the stack without removing it
let topItem = stack.Peek();
Debug.Log("Top element of the stack: ", topItem);