Skip to content
/ KPEdit Public

Quick Key Path Edit. The compiler is unable to type-check this expression in reasonable time; 🤠

License

Notifications You must be signed in to change notification settings

0xLeif/KPEdit

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

KPEdit

Quick KeyPath Editting

Example Usage

/*
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

CleanShot 2020-08-21 at 17 20 26

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!

var dumb = DumbStruct()
        
(((dumb + \.string - "Hello!")
     + \.double - 3.14)
     + \.array - [1, 43, 6, true])

XCTAssertEqual(dumb.string, "Hello, World!")

About

Quick Key Path Edit. The compiler is unable to type-check this expression in reasonable time; 🤠

Topics

Resources

License

Stars

Watchers

Forks

Languages