Skip to content

Instantly share code, notes, and snippets.

@salmaanahmed
Created January 28, 2019 12:00
Show Gist options
  • Save salmaanahmed/4bb61c8ac7860b3ff699ba20d90c0083 to your computer and use it in GitHub Desktop.
Save salmaanahmed/4bb61c8ac7860b3ff699ba20d90c0083 to your computer and use it in GitHub Desktop.
Add two computed properties, isEven and isOdd, and a function isMultiple to the BinaryInteger protocol.
// On protocol BinaryInteger
@_transparent
public var isEven: Bool { return _lowWord % 2 == 0 }
@_transparent
public var isOdd: Bool { return !isEven }
func isMultiple(of other: Self) -> Bool
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment