Created
March 21, 2015 10:50
-
-
Save phamquochoan/2fffda84176c5c8edec0 to your computer and use it in GitHub Desktop.
Increase or decrease enum's raw value by one point if it's kind of FloatingPoint or Integer
This file contains 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
postfix func ++ <T: RawRepresentable, V: FloatingPointType>(lhs: T) -> V { | |
return (lhs.rawValue as! V) + 1 | |
} | |
postfix func -- <T: RawRepresentable, V: FloatingPointType>(lhs: T) -> V { | |
return (lhs.rawValue as! V) - 1 | |
} | |
postfix func ++ <T: RawRepresentable, V: IntegerType>(lhs: T) -> V { | |
return (lhs.rawValue as! V) + 1 | |
} | |
postfix func -- <T: RawRepresentable, V: IntegerType>(lhs: T) -> V { | |
return (lhs.rawValue as! V) - 1 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment