Last active
August 29, 2015 14:04
-
-
Save rbrockerhoff/c5b2c1ea7a9d3f5b142b to your computer and use it in GitHub Desktop.
Must be a Swift bug
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
extension Dictionary { | |
mutating func merge <S: Sequence where S.GeneratorType.Element == Element> (seq: S) { | |
var gen = seq.generate() | |
while let (key: KeyType, value: ValueType) = gen.next() { | |
self[key] = value | |
} | |
} | |
} | |
var dict = [0:0] | |
let more = [1,2,3] | |
dict.merge(more) // this should give a syntax error, right? But... | |
println(dict) // prints [0: 0, 1: 140735543552768, 2: 140735543552768, 3: 140735543552768] | |
// Update: apparently it matches only against the KeyType, so [KeyType] and [(KeyType, AnyType)] work. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Filed a bug: http://www.openradar.me/17754431