pau-riquelme

Untitled

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