Named parameter

What if we told you that while calling, it's not mandatory to pass the parameter in the same sequence that is defined in the function signature? Believe us. With Kotlin's named parameter feature, it's no longer a constraint. Take a look at the following function that has a nickName parameter and the second parameter is message:

    private fun logMessageFromMe(nickName: String, message: String) {      val onlineUsersList = document.getElementById("chatMessages")      val li = document.create.li {        div(classes = "sentMessages") {          span(classes = "chatMessage") {            +message          }          span(classes = "filledInitialsMe") {            +getInitials(nickName)          }        }      }    onlineUsersList?.appendChild(li)    }

If you call a function such as logMessageForMe(mrssage,nickName), it ...

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.