Even and Odd Integers

There may well be lots of good uses out there that can be enumerated in a proposal, just saying I'd be wary of GitHub counts. My (unscientifically conducted) review of a sample of these 4,000 results suggests they are almost entirely:

  • unused extensions (i.e. lots of copies of the definition of isEven in the same IntExtensions.swift file, but hardly any calls to it); or
  • sample code using isEven as an example of a function being passed to a higher-order function like filter. Makes sense – it's my go-to example function to use for these purposes too! (But defining it as a property would be unsatisfactory for these purposes since I usually want to use it point-free :)

Several of the handful of real uses I could spot were ones that have better equivalents: for example, arc4random().isEven for a version of Bool.random().

6 Likes