June 2018
Intermediate to advanced
310 pages
6h 32m
English
The next day, your product manager reaches out to you. Apparently, they want a SadMap now, which gets sad each time a key is removed from it. Following the previous pattern, you extend the map again:
class SadMap<K, V>: HashMap<K, V>() { override fun remove(key: K): V? { println("Okay...") return super.remove(key) }}
But then the chief architect asks that in some cases, a map would be happy and sad at the same time. The CTO already has a great idea for a SuperSadMap that will print the following output twice:
Okay...
So, what we need is the ability to combine the behaviors of our objects.
Read now
Unlock full access