Created
October 28, 2015 23:52
-
-
Save anonymous/75b879c6030da3441a83 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>(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