Skip to content

Instantly share code, notes, and snippets.

@kalub92
Created March 12, 2018 23:29
Show Gist options
  • Save kalub92/19aef6ed0fd2746966e817c035234d2b to your computer and use it in GitHub Desktop.
Save kalub92/19aef6ed0fd2746966e817c035234d2b to your computer and use it in GitHub Desktop.
import Foundation
struct Stack {
private var items: [String] = []
func peek() -> String {
guard let topElement = items.first else { fatalError("This stack is empty.") }
return topElement
}
mutating func pop() -> String {
return items.removeFirst()
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment