https://github.com/0xleif/kpedit
Quick Key Path Edit. The compiler is unable to type-check this expression in reasonable time; ðŸ¤
https://github.com/0xleif/kpedit
keypath swift
Last synced: 6 months ago
JSON representation
Quick Key Path Edit. The compiler is unable to type-check this expression in reasonable time; ðŸ¤
- Host: GitHub
- URL: https://github.com/0xleif/kpedit
- Owner: 0xLeif
- License: mit
- Created: 2020-08-21T21:59:39.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2020-08-21T22:25:10.000Z (over 5 years ago)
- Last Synced: 2025-04-05T12:29:44.322Z (11 months ago)
- Topics: keypath, swift
- Language: Swift
- Homepage:
- Size: 6.84 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# KPEdit
Quick KeyPath Editting
### Example Usage
```swift
/*
class SomeObject {
var value = ""
}
*/
let someValue = SomeObject()
print(someValue.value) // Output: ""
/*
(ObjectForKeyPath) + (KeyPath) - (ValueOfKeyPath)
*/
someValue + \.value - "Hello World"
print(someValue.value) // Output: "Hello World"
```
#### Known Issue

> error: the compiler is unable to type-check this expression in reasonable time; try breaking up the expression into distinct sub-expressions
dumb + \.string - "Hello!" + \.double - 3.14 + \.array - [1, 43, 6, true]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~
#### Solution
**Make sure to use parentheses!**
```swift
var dumb = DumbStruct()
(((dumb + \.string - "Hello!")
+ \.double - 3.14)
+ \.array - [1, 43, 6, true])
XCTAssertEqual(dumb.string, "Hello, World!")
```