कॉटलीन मधील एक्स्टेंशन function

कॉटलीन मधील एक्स्टेंशन function

ह्याचा उपयोग क्लास मध्ये एखादी method क्लास मध्ये ऍड करण्यासाठी होतो.

fun main(args : Array<String>)
{


        val  et : ExtensionTest = ExtensionTest()

        et.simpleExtension()

        et.newfunction()


}

class ExtensionTest
{
    fun simpleExtension()
    {
        println("You called simpleExtension")
    }
}

fun ExtensionTest.newfunction()
{
    println("you called new Extension function")
}

आउटपुट 

You called simpleExtension
you called new Extenstion function

Comments

Popular posts from this blog

डिफॉल्ट arguments function

सिम्पल क्लास example

कॉटलीन डेटाटाइप