DEV Community

Discussion on: Explain Generics Like I'm Five

Collapse
 
thermatix profile image
Martin Becker

I think this is the best explanation, but you might want to add how this maps to code as this is very abstracted away from code.

Collapse
 
alainvanhout profile image
Alain Van Hout • Edited

Given that this is an #explainlikeimfive post, abstracting away from the code is rather a fundamental requirement :).

But for completeness sake: the original books would have been the UnicornBook, DragonBook and LabradorBook classes, which are nearly identical expect wherever the Unicorn, Dragon or Labrador classes (or their instances) are used. The generic equivalent would ba a Book where T can be added for whatever you like, to create e.g. Book< Unicorn > or Book< Eagle >.

Hope that helps :-).

Thread Thread
 
thermatix profile image
Martin Becker

Heh, totally get where your coming from.