Skip to content

Instantly share code, notes, and snippets.

View yacir's full-sized avatar

Yassir Barchi yacir

View GitHub Profile
@yacir
yacir / BinaryInteger+Utils.swift
Last active July 15, 2020 14:29
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 }
}