Skip to content

Instantly share code, notes, and snippets.

@nubbel
Last active August 29, 2015 14:04
Show Gist options
  • Select an option

  • Save nubbel/ffeec3b7146689d4fcde to your computer and use it in GitHub Desktop.

Select an option

Save nubbel/ffeec3b7146689d4fcde to your computer and use it in GitHub Desktop.
infix operator < { associativity left }
func <<T : Comparable>(lhs: T, rhs: T) -> ((T, T) -> Bool, () -> T) -> Bool {
return { (op: (T, T) -> Bool, value: () -> T) in
(lhs < rhs) && op(rhs, value())
}
}
func <<T: Comparable>(lhs: ((T, T) -> Bool, () -> T) -> Bool, rhs: @autoclosure () -> T) -> Bool {
return lhs({$0 < $1}, rhs)
}
var x: Int = 5
if 1 < x < 10 {
true
}
else {
false
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment