« first day    last day (23 days later) » 

7:19 AM
@Alexander I forgot to ask. is var products: [ProductID : Product] better or just var products: [Product] with the latter I'd have to search products or find a certain productID, the dictionary doesn't have that issue
 
 
11 hours later…
5:52 PM
It totally depends @Honey
If you're looking up products by their ID, then using a dict makes a lot more sense
 
6:10 PM
@Alexander how else would like them up then? Name? Still My question is should I be using dictionary or array? I can always use array and loop through. But don't think that's a good choice...
right?
 
6:29 PM
No, because that's much slower
and you look up things by ID often enough to make a dictionary worthwhile
 
 
1 hour later…
7:33 PM
@Alexander This is stupid to say, but when you see ["123" : productX, 345 : productY] vs [productX, productY], you might side with the shorter version. Because generally in the interviews, your mindset is aiming to get things done in lesser number of lines. But that seems totally wrong here. I should change my mindset
 
 
2 hours later…
9:30 PM
@Honey What I would rather see is: Dictionary(uniqueKeysWithValues: [productX, productY].map { ($0.id, $0) })
 

« first day    last day (23 days later) »