Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
turn foo.xInPlace(arg) into a foo.x(arg)...
func modifiedCopy<Struct, Arg>(start: Struct, @noescape mutator: (inout Struct) -> Arg -> (), arg: Arg) -> Struct {
var new = start
mutator(&new)(arg)
return new
}
extension Array {
func arrayByAppending(e: Element) -> Array {
return modifiedCopy(self, mutator: Array.append, arg: e)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.