Function stack::top()

← Back to Class stack



Module adtClass stack → top()

Description

Retrieve but not remove the top of the Stack, or return nothing if the Stack is empty

stack::top()


Parameters

There are no parameters.


Return Value


Usage Example

import adt/stack
 
stack = stack()
 
stack.push(10)
stack.push(12)
stack.push(8)
 
writeln(stack.top())   ' Output: 8
writeln(stack.top())   ' Output: 8