Default arguments in functions

Unlike Java function arguments, Kotlin supports default arguments in functions. This enables flexible function writing, as in the following code:

fun withDefaultValues(name : String = "Shazin", age : Int = 32) {
println("Name $name and Age $age");
}

The preceding function can be called as follows:

withDefaultValues();
withDefaultValues("Shahim", 32);
..................Content has been hidden....................

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