Created
November 28, 2016 19:12
-
-
Save marciok/347c00b57b6c41667966cb1a0a9f6650 to your computer and use it in GitHub Desktop.
Is that a bug? π€
This file contains hidden or 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
| // It seems like Swift cannot correctly infer the type on the *second element* of the expression | |
| func postOrder(_ node: Node?) -> [Int] { | |
| guard let node = node else { return [] } | |
| return [node.content] + postOrder(node.left) + postOrder(node.right) // β ERROR: 'Int' is not convertible to [Int] | |
| } | |
| // If I specify than it works... | |
| func postOrder(_ node: Node?) -> [Int] { | |
| guard let node = node else { return [] } | |
| return [node.content] + postOrder(node.left) + (postOrder(node.right) as [Int]) // β That works | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment