MCPcopy Create free account
hub / github.com/crossoverJie/gscript / Pop

Method Pop

stack/stack.go:29–35  ·  view source on GitHub ↗

Pop Remove and return top element of Stack. Return false if Stack is empty.

()

Source from the content-addressed store, hash-verified

27
28// Pop Remove and return top element of Stack. Return false if Stack is empty.
29func (s *Stack) Pop() interface{} {
30 index := len(*s) - 1 // Get the index of the top most element.
31 element := (*s)[index] // Index into the slice and obtain the element.
32 *s = (*s)[:index] // Remove it from the Stack by slicing it off.
33 return element
34
35}
36
37// Peek Peek value, not remove element.
38func (s *Stack) Peek() interface{} {

Callers 5

initClassObjectMethod · 0.95
TestStack_PeekFunction · 0.95
TestStack_GetFunction · 0.95
popStackMethod · 0.80
popScopeMethod · 0.80

Calls

no outgoing calls

Tested by 2

TestStack_PeekFunction · 0.76
TestStack_GetFunction · 0.76