December 2017
Beginner
372 pages
10h 32m
English
A function or a class is defined generic by introducing a type parameter. Type parameter defines what type the function parameters or class instance should be. Type parameter is not the regular parameter that is passed to a function but a special kind of parameter, which lets us define the type. The type parameter is defined inside angle brackets after the function or class name. In generics, a type parameter is normally defined as T, but it's just a convention and you can define it with any letter. The actual type a function or class will be used is defined at the time of calling the said function or class instance.
Read now
Unlock full access