Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save phamquochoan/2fffda84176c5c8edec0 to your computer and use it in GitHub Desktop.
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
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