Skip to content

Instantly share code, notes, and snippets.

@zydeco
Last active April 27, 2016 08:36
Show Gist options
  • Save zydeco/5b8e39ead58d52770580 to your computer and use it in GitHub Desktop.
Save zydeco/5b8e39ead58d52770580 to your computer and use it in GitHub Desktop.
goes toward operator
infix operator --> { associativity left precedence 80 }
func --><T:IntegerType>(inout left:T, right:T) -> Bool {
if left != right {
left = left.advancedBy(left > right ? -1 : 1)
return true
} else {
return false
}
}
// example use
var i = 6
print("6 --> 0")
while i --> 0 {
print(i)
}
// also goes up
i = 3
print("3 --> 6")
while i --> 6 {
print(i)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment