[swift-users] Why can't we get `URL` equal on the same path?

Zhao Xin owenzx at gmail.com
Fri Oct 14 09:33:17 CDT 2016


As you can see, `URL` is not equal but the `path` is. I wonder why urls do
not equal here?

let url = URL(fileURLWithPath: "foo/bar", isDirectory: false)

let baseURL = url.deletingLastPathComponent()

let newURL = URL(fileURLWithPath: "bar", isDirectory: false, relativeTo:
baseURL)


print(url == newURL) // prints false

print(url.path == newURL.path) // prints true

Zhaoxin
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-users/attachments/20161014/1b5f4a1d/attachment.html>


More information about the swift-users mailing list