-
-
Save natecook1000/c3ebce76c81f5254b3d6 to your computer and use it in GitHub Desktop.
turn foo.xInPlace(arg) into a foo.x(arg)...
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func modifiedCopy<Struct, Arg>(var start: Struct, @noescape mutator: (inout Struct) -> Arg -> (), arg: Arg) -> Struct { | |
mutator(&start)(arg) | |
return start | |
} | |
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