Skip to content

Instantly share code, notes, and snippets.

@k0nserv
Last active September 2, 2015 18:45
Show Gist options
  • Save k0nserv/86b0c7a7888233f8b32c to your computer and use it in GitHub Desktop.
Save k0nserv/86b0c7a7888233f8b32c to your computer and use it in GitHub Desktop.
This code makes xCode sad under xCode 7 Beta 6(7A192o)
private func nestedEquality<T>(lhs: [[T]], _ rhs: [[T]], equal: ([T], [T]) -> Bool) -> Bool {
if lhs.count != rhs.count {
return false
}
for var i = 0; i < lhs.count; i++ {
if false == equal(lhs[i], rhs[i]) {
return false
}
}
return true
}
@cennydavidsson
Copy link

I'm pretty sure == do this to nested arrays if T is Equitable

let nestedA = [[1,2], [3,2]]
let nestedB = [[1,2], [3,1]]

nestedA == nestedB // false
nestedA == nestedA // true

Here is an cleaner and clearer way in my opinion to write that for loop

for (i, _) in lhs.enumerate() where equal(lhs[i], rhs[i]) {
        return false
    }

@k0nserv
Copy link
Author

k0nserv commented Sep 2, 2015

Thing is the condition varies from time to time, anyways it sovled itself somehow :)

https://github.com/k0nserv/SwiftObjLoader/blob/master/SwiftObjLoader/Geometry.swift#L39-L109

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment