Deviopath › Go

Stock Lookup

Easy · Maps

The two-value map lookup value, ok := stock[item] tells you whether the key exists. Missing keys yield the zero value (0 for int) and ok == false.

Write StockOf(stock, item) that returns the count for item, or 0 if it is missing.

Next: Word Count