Last active
          April 27, 2016 08:36 
        
      - 
      
- 
        Save zydeco/5b8e39ead58d52770580 to your computer and use it in GitHub Desktop. 
    goes toward operator
  
        
  
    
      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
    
  
  
    
  | 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