Skip to content

Instantly share code, notes, and snippets.

@alexito4 alexito4/hang.swift
Last active Sep 4, 2015

Embed
What would you like to do?
Is this not valid in Swift? Tried on Xcode 7b6
protocol Stack {
typealias Element
mutating func push(value: Element)
mutating func pop() -> Element?
}
struct ArrayStack<T>: Stack {
....
}
extension Stack where Self: ArrayLiteralConvertible {
init(arrayLiteral elements: Self.Element...) {
self.init()
print("array literal init")
for value in elements {
push(value)
}
}
}
extension ArrayStack: ArrayLiteralConvertible {}
print("before")
var tin: ArrayStack = [1, 2, 3]
print("after") // this never gets called.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.