Dynamic Members

This commit is contained in:
Max Howell
2019-01-22 14:05:33 -05:00
parent 44be1c45a9
commit 859164e59f
5 changed files with 41 additions and 5 deletions

View File

@@ -94,6 +94,18 @@ decoder.userInfo[.relativePath] = Path.home
decoder.decode(from: data)
```
## Dynamic members
We support `@dynamicMemberLookup`:
```swift
let ls = Path.root.usr.bin.ls // => /usr/bin/ls
```
This is less commonly useful than you would think, hence our documentation
does not use it. Usually you are joining variables or other `String` arguments.
However when you need it, its *lovely*.
## Initializing from user-input
The `Path` initializer returns `nil` unless fed an absolute path; thus to