Skip to content

Instantly share code, notes, and snippets.

@thexande
Created January 29, 2019 16:49
Show Gist options
  • Select an option

  • Save thexande/377dd5660ffaf35b062852fe81251372 to your computer and use it in GitHub Desktop.

Select an option

Save thexande/377dd5660ffaf35b062852fe81251372 to your computer and use it in GitHub Desktop.
Swift Stack Implementation
struct Stack<T> {
private var stack: [T] = []
mutating func push(_ item: T) {
stack.append(item)
}
mutating func pop() -> T {
return stack.removeLast()
}
func peek() -> T? {
return stack.last
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment