Named arguments in Kotlin
Level 3195 keystrokes
With named arguments (name = value) each value is matched to its parameter by name, so calls are easier to read and the order can be changed freely.
Kotlin code
// A function with three parameters of different types1fun createUser(name: String, age: Int, active: Boolean) { // Print the three values separated by commas2 println("$name, $age, $active")3}4 // Named arguments in declaration order: prints Alice, 25, true5createUser(name = "Alice", age = 25, active = true)// Order changed, but names map each value correctly: prints Bob, 30, false6createUser(active = false, name = "Bob", age = 30)Output
Alice, 25, true Bob, 30, false
Practice typing this code. Results are not recorded in the rankings.
Symbols in this code
The symbols you type in this Kotlin code and how often they appear.
,× 8"× 6=× 6(× 4)× 4:× 3$× 3{× 1}× 1