Protocol-oriented programming

protocol TeamRecord {
  var wins: Int { get }
  var losses: Int { get }
  var winningPercentage: Double { get }
}

extension TeamRecord {
  var gamesPlayed: Int {
    wins + losses
  }
}

extension TeamRecord {
  var winningPercentage: Double {
    Double(wins) / Double(wins + losses)
  }
}
The book says :
While this is much like the protocol extension you defined
 in the previous example, it differs in that winningPercentage
 is a member of the TeamRecord protocol itself, 
whereas gamesPlayed isn’t.

my question is Why these extensions are different ?

This topic was automatically closed after 166 days. New replies are no longer allowed.