Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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
You can’t perform that action at this time.