Last active
September 4, 2015 07:00
-
-
Save alexito4/ef20d0e81535ae5b027e to your computer and use it in GitHub Desktop.
Is this not valid in Swift? Tried on Xcode 7b6
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
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