Sort Properties After Creation#175
Sort Properties After Creation#175LePips wants to merge 6 commits intoCreateAPI:mainCreateAPI/CreateAPI:mainfrom LePips:sortPropertiesAlphabetically-proper-sortingLePips/CreateAPI:sortPropertiesAlphabetically-proper-sortingCopy head branch name to clipboard
Conversation
|
Interesting, the tests' type checker couldn't do that inference, I think due to Edit: Edit edit: Minimal Examplelet handleWarningAsError = false
func handle<T>(warning: String) -> T? {
if handleWarningAsError {
fatalError()
} else {
print(warning)
return nil
}
}
let keys = ["foo", "bar"]
struct Property {
let name: String
let uuid = UUID()
}
let properties = keys.compactMap { key in // Error: ambiguous, fix with [Property]
if key == "foo" {
return handle(warning: "You are foo, I don't like you")
}
return Property(name: key)
}
print(properties) |
|
@liamnichols I apologize for the ping, could this and #177 receive a review as I would like to go ahead with some work that would use these features. Thank you! |
liamnichols
left a comment
There was a problem hiding this comment.
Hi @LePips, really sorry about the delay in getting though these notifications! Thanks for taking the time to work on this, I really appreciate it!
The changes looks good to me assuming that it is doing what you say it does, but could you maybe replicate it in the tests somehow so that we can be sure not to break the behaviour in the future by mistake? 🙏
useSwiftyPropertyNamesandsortPropertiesAlphabeticallyordering #174Sorts created properties, which go through their own independent renamings if applicable, instead of the raw keys.