Draget
12/12/2020, 5:10 PMif (!myMap.containsKey(color) || myMap[color]!!.isEmpty()) return 1Milan Hruban
12/12/2020, 5:20 PMmyMap[color]?.isEmpty() != falseDraget
12/12/2020, 5:23 PMMilan Hruban
12/12/2020, 5:45 PMif statement is not part of that expression.
with the expression I wrote, you have several cases:
1. The item is not in the map, so you get null?.isEmpty() which evaluates to null, so null != false -> true
2. the item is in the map, but it is empty, so you get theEmptyItem?.isEmpty(), which evaluates to true so true != false -> true
3. the item is in the map and it is not empty, so you get notEmptyItem?.isEmpty(), which evaluates to false so false != false -> falseDraget
12/12/2020, 5:47 PMnull?.something() == null would be true?
I get it, thanks. 🙂Milan Hruban
12/12/2020, 5:48 PMgeorg
12/12/2020, 8:45 PMDraget
12/12/2020, 9:51 PM