Named parameter

We simply love this feature. A named parameter is something where you can bind the values with the parameter name, irrespective of the sequence of the parameter.  The problem statement here is often that while dealing with the bad/legacy code, we came across two such methods where we have a huge list of parameters and we don't know which one is what parameter.

Assume that code is written like this:

    fun complexMathCalculation(height: Int, scaleFactor: Float,        displayValue: String, fromUser: Boolean, width: Int, colorCode:      String): Int {      // Code goes here      return 0     }

And somewhere it's getting called as follows: 

    fun void draw() {      complexMathCalculation(10,5f,"Kotlin",true,50,"#FFFFFF");    }

By looking at the preceding code ...

Get Kotlin Blueprints now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.