DEV Community

Discussion on: Comparing Array-Based Stacks in C and Go

Collapse
 
mattconn profile image
Matthew Connelly

Sorry, I just saw this comment. It is to make sure changes to top persist outside of the push function, so that top always refers to the top of the stack if top > -1.
You could also make top static to achieve persistence, but then that would give push ownership of top and I want push to work for any stack.