Skip to content

Instantly share code, notes, and snippets.

@yacir
Last active July 15, 2020 14:29
Show Gist options
  • Save yacir/58283aed0e43848a64f7317c8f5ad1f0 to your computer and use it in GitHub Desktop.
Save yacir/58283aed0e43848a64f7317c8f5ad1f0 to your computer and use it in GitHub Desktop.
A simple π—Άπ˜€π—’π—±π—± & π—Άπ˜€π—˜π˜ƒπ—²π—» extension to the π—œπ—»π˜π—²π—΄π—²π—Ώ type, which might come handy in many situations.
extension BinaryInteger {
/// Returns true if and only if this integer is even.
var isEven: Bool { return self % 2 == 0 }
/// Returns true if and only if this integer is odd.
var isOdd: Bool { return self % 2 != 0 }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment