repl.it
Swift

1234567

fork
loading
Files
  • main.swift
main.swift
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
struct Stack<Element> {
    var items = [Element]()
    mutating func push(_ item: Element) {
        items.append(item)
    }
    mutating func pop() -> Element {
        return items.removeLast()
    }
}

var stackOfStrings = Stack<String>()
stackOfStrings.push("uno")
stackOfStrings.push("dos")
stackOfStrings.push("tres")
stackOfStrings.push("cuatro")
print(stackOfStrings.pop())
print(stackOfStrings.pop())
Fetching token
?