Generics in functions

Kotlin supports generics in functions to avoid code duplication. This is shown with the following code:

fun <T> genericFunction(t : T) {
println(t);
}

This function can be invoked as follows:

genericFunction("Shazin");
genericFunction(123);
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.147.66.128