Skip to content

Instantly share code, notes, and snippets.

@mikeash
Created October 28, 2014 18:29
Show Gist options
  • Save mikeash/e0b00cd469125f1ed17c to your computer and use it in GitHub Desktop.
Save mikeash/e0b00cd469125f1ed17c to your computer and use it in GitHub Desktop.
struct IterateVars<T> {
let f: T -> T
func go(inout x: T) -> IterateVars {
x = f(x)
return self
}
}
var a = 2.0;
var b = 3.0;
var c = 4.0;
var d = 5.0;
IterateVars{ $0 * 2 }.go(&a).go(&b).go(&c).go(&d)
IterateVars{ $0 + 10 }.go(&a).go(&b).go(&c).go(&d)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment