Skip to content

Instantly share code, notes, and snippets.

@alexito4
Last active September 4, 2015 07:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save alexito4/ef20d0e81535ae5b027e to your computer and use it in GitHub Desktop.
Save alexito4/ef20d0e81535ae5b027e to your computer and use it in GitHub Desktop.
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