[swift-users] Why can't we get `URL` equal on the same path?
Greg Parker
gparker at apple.com
Fri Oct 14 16:40:49 CDT 2016
> On Oct 14, 2016, at 7:33 AM, Zhao Xin via swift-users <swift-users at swift.org> wrote:
>
> 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
Here's one reason:
print(url.baseURL == newURL.baseURL) // prints false
--
Greg Parker gparker at apple.com <mailto:gparker at apple.com> Runtime Wrangler
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-users/attachments/20161014/98cba466/attachment.html>
More information about the swift-users
mailing list