January 2018
Intermediate to advanced
434 pages
14h 1m
English
Another step forward to reduce the number of overloads and increase code readability is to use named arguments. Let's take look at the following code:
fun main(args: Array<String>) { foo(b=0.9) foo(a=1,c="Custom string")} fun foo(a:Int=0, b: Double =0.0, c:String="some default value"){ println("a=$a , b=$b ,c = $c")}
Output:a=0 , b=0.9 ,c = some default valuea=1 , b=0.0 ,c = Custom string
Read now
Unlock full access