Delegated map
So, we learned how to use standard delegates, but Kotlin has to offer more with delegation. The map delegation is among those awesome features that comes with delegation. So, what is it? It is the freedom of passing a map as a single parameter instead of numbers of parameters in a function/class constructor. Let's have a look. The following is a program applying map delegation:
data class Book (val delegate:Map<String,Any?>) { val name:String by delegate val authors:String by delegate val pageCount:Int by delegate val publicationDate:Date by delegate val publisher:String by delegate } fun main(args: Array<String>) { val map1 = mapOf( Pair("name","Reactive Programming in Kotlin"), Pair("authors","Rivu Chakraborty"), Pair("pageCount",400), Pair("publicationDate",SimpleDateFormat("yyyy/mm/dd").parse("2017/12/05")), Pair("publisher","Packt") ) val map2 = mapOf...