Created
March 12, 2018 23:29
-
-
Save kalub92/19aef6ed0fd2746966e817c035234d2b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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