4 ms·
I'm not sure if it's XCode / playground acting up, but array equality is broken for me: `[1, 2, 3] == [1, 2, 3]` returns false. This seems to contradict the co
by jiaweihli 12y ago
I'm not sure if it's XCode / playground acting up, but array equality is broken for me: `[1, 2, 3] == [1, 2, 3]` returns false. This seems to contradict the core declarations though:
/// Returns true if these arrays contain the same elements.
func ==<T : Equatable>(lhs: T[], rhs: T[]) -> Bool
Works alright for dictionaries. Is there a bug tracker for Swift anywhere to report this?
Edit:
Whoops, copied wrong declaration. ContiguousArrays actually work fine, but require an extra cast. e.g.
ContiguousArray([1, 2, 3]) == ContiguousArray([1, 2, 3])
- lcnmrn 12y agovar one = [1, 2, 3] var two = [1, 2, 3] one == two That's because Swift checks for safety first (variable declaration).
- jiaweihli 12y agoCan you explain what you mean by `checks for safety first (variable declaration)`? This issue only seems to affect arrays. Strings, numbers, and dictionaries are fine.