pau-riquelme

Untitled

Oct 4th, 2017
584
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Swift 0.33 KB | None | 0 0
  1.  
  2. struct InventoryList< T > {
  3.    var items: [T]
  4.  
  5.    mutating func add(item: T) {
  6.        items.append(item)
  7.    }
  8.  
  9.    mutating func remove() -> T {
  10.        return items.removeLast()
  11.    }
  12.  
  13.    func isCapacityLow() -> Bool {
  14.        return items.count < 3
  15.    }
  16.  
  17.    func numberOfItems() -> Int {
  18.        return items.count
  19.    }
  20. }
Advertisement
Add Comment
Please, Sign In to add comment