Skip to content

Instantly share code, notes, and snippets.

@ayanonagon
Created November 22, 2015 00:53
Show Gist options
  • Save ayanonagon/d857926896c19ba09602 to your computer and use it in GitHub Desktop.
Save ayanonagon/d857926896c19ba09602 to your computer and use it in GitHub Desktop.
class Cart {
let items: [Item]
var total: UInt {
return items.reduce(0) { sum, item in
sum + item.price
}
}
init(items: [Item]) {
self.items = items
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment