Created
August 8, 2018 12:33
-
-
Save mortenbekditlevsen/fa74e0cd7737e53bda05d22fcf9b3b42 to your computer and use it in GitHub Desktop.
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
// So from the Objc.io talk, we learn about a way of representing filesystem paths that can point to either files or directories. | |
// Internally, these are represented as an array of path elements. Let's do that too: | |
public struct Path<Element> { | |
private var components: [String] | |
fileprivate func append<T>(_ args: String ...) -> Path<T> { | |
return Path<T>(components + args) | |
} | |
fileprivate init(_ components: [String]) { | |
self.components = components | |
} | |
var rendered: String { | |
return components.joined(separator: "/") | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment