Upgrade to Pro — share decks privately, control downloads, hide ads and more …

10 lessons we can learn from the 30,886 (and co...

10 lessons we can learn from the 30,886 (and counting) Swift commits

Simone Civetta

January 04, 2016
Tweet

More Decks by Simone Civetta

Other Decks in Programming

Transcript

  1. 10 LESSONS WE CAN LEARN FROM THE 30,886 (AND COUNTING)

    SWIFT COMMITS (AND IT'S NOT A CLICKBAIT)
  2. 10 LESSONS WE CAN LEARN FROM THE 30,886 (AND COUNTING)

    SWIFT COMMITS (OK, IT'S A CLICKBAIT)
  3. Template %{ integerBinaryOps = [ (x[:-1], x[-1], x[:-1].capitalize(), 'a result')

    for x in 'add+ subtract- multiply* divide/'.split() ] + [ ('remainder', '%', 'Divide', 'the remainder') ] }% Usage public protocol _IntegerArithmeticType { % for name,_,Action,result in integerBinaryOps: /// ${Action} `lhs` and `rhs`, returning ${result} and a `Bool` that is /// true iff the operation caused an arithmetic overflow. static func ${name}WithOverflow(lhs: Self, _ rhs: Self) -> (Self, overflow: Bool) % end }
  4. /// Insert `newElement` at index `i`. /// /// Invalidates all

    indices with respect to `self`. /// /// - Complexity: O(`self.count`). public mutating func insert(newElement: Character, atIndex i: Index) { withMutableCharacters { (inout v: CharacterView) in v.insert(newElement, atIndex: i) } }