{"id":1342,"date":"2019-03-26T12:56:39","date_gmt":"2019-03-26T07:26:39","guid":{"rendered":"http:\/\/blog.openwebsolutions.in\/?p=1342"},"modified":"2019-03-26T12:56:39","modified_gmt":"2019-03-26T07:26:39","slug":"kotlin-programming-features-implementing-extension-function","status":"publish","type":"post","link":"https:\/\/openwebsolutions.in\/blog\/kotlin-programming-features-implementing-extension-function\/","title":{"rendered":"Kotlin Programming features in implementing of Extension function"},"content":{"rendered":"<p>The purpose of extension functions is to add new functions to the existing class which means it can simply add functions to the class without declearing it inside the class. The new function actually behaves like static. It can become part of your own class (like Student) or can become part of the predefined class(like String, Int, Array etc). This function reduces the code and code become much easier and cleaner to read.<\/p>\n<p><b>Ex<\/b>&#8211;<\/p>\n<p>fun main(args, Array&lt;String&gt;){<\/p>\n<p>var student = Student()<\/p>\n<p>println(\u201cPassed status : \u201d + student . HasPassed(57))<\/p>\n<p>println(\u201cScholar status : \u201d + student . isScholar(57))<\/p>\n<p>}<\/p>\n<p>fun Student . isScholar(marks : Int) : Boolean{ \/\/Extension of your own class<\/p>\n<p>return marks &gt; 95<\/p>\n<p>}<\/p>\n<p>class Student{ \/\/ Your own Class<\/p>\n<p>fun hasPassed(marks : Int) : Boolean{<\/p>\n<p>return marks &gt; 40<\/p>\n<p>}<\/p>\n<p>}<\/p>\n<p><b>Output :<\/b><\/p>\n<p>Passed status : true<\/p>\n<p>Scholar status : false<\/p>\n","protected":false},"excerpt":{"rendered":"<p>The purpose of extension functions is to add new functions to the existing class which means it can simply add functions to the class without declearing it inside the class. The new function actually behaves like static. It can become part of your own class (like Student) or can become part of the predefined class(like [&hellip;]<\/p>\n","protected":false},"author":35,"featured_media":1441,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[94,18],"tags":[95,87],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v14.8.1 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Kotlin Programming features in implementing of Extension function<\/title>\n<meta name=\"robots\" content=\"index, follow\" \/>\n<meta name=\"googlebot\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<meta name=\"bingbot\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/openwebsolutions.in\/blog\/kotlin-programming-features-implementing-extension-function\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Kotlin Programming features in implementing of Extension function\" \/>\n<meta property=\"og:description\" content=\"The purpose of extension functions is to add new functions to the existing class which means it can simply add functions to the class without declearing it inside the class. The new function actually behaves like static. It can become part of your own class (like Student) or can become part of the predefined class(like [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/openwebsolutions.in\/blog\/kotlin-programming-features-implementing-extension-function\/\" \/>\n<meta property=\"og:site_name\" content=\"Openweb Solutions Blog\" \/>\n<meta property=\"article:published_time\" content=\"2019-03-26T07:26:39+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/openwebsolutions.in\/blog\/wp-content\/uploads\/2019\/03\/extension-functions.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"2048\" \/>\n\t<meta property=\"og:image:height\" content=\"1342\" \/>\n<meta name=\"twitter:card\" content=\"summary\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebSite\",\"@id\":\"https:\/\/openwebsolutions.in\/blog\/#website\",\"url\":\"https:\/\/openwebsolutions.in\/blog\/\",\"name\":\"Openweb Solutions Blog\",\"description\":\"Transforming ideas into reality\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":\"https:\/\/openwebsolutions.in\/blog\/?s={search_term_string}\",\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"en-US\"},{\"@type\":\"ImageObject\",\"@id\":\"https:\/\/openwebsolutions.in\/blog\/kotlin-programming-features-implementing-extension-function\/#primaryimage\",\"inLanguage\":\"en-US\",\"url\":\"https:\/\/openwebsolutions.in\/blog\/wp-content\/uploads\/2019\/03\/extension-functions.jpg\",\"width\":2048,\"height\":1342},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/openwebsolutions.in\/blog\/kotlin-programming-features-implementing-extension-function\/#webpage\",\"url\":\"https:\/\/openwebsolutions.in\/blog\/kotlin-programming-features-implementing-extension-function\/\",\"name\":\"Kotlin Programming features in implementing of Extension function\",\"isPartOf\":{\"@id\":\"https:\/\/openwebsolutions.in\/blog\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/openwebsolutions.in\/blog\/kotlin-programming-features-implementing-extension-function\/#primaryimage\"},\"datePublished\":\"2019-03-26T07:26:39+00:00\",\"dateModified\":\"2019-03-26T07:26:39+00:00\",\"author\":{\"@id\":\"https:\/\/openwebsolutions.in\/blog\/#\/schema\/person\/990bda7c6fac1aa9c1ffde7745f42628\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/openwebsolutions.in\/blog\/kotlin-programming-features-implementing-extension-function\/\"]}]},{\"@type\":\"Person\",\"@id\":\"https:\/\/openwebsolutions.in\/blog\/#\/schema\/person\/990bda7c6fac1aa9c1ffde7745f42628\",\"name\":\"Arindam Kundu\",\"image\":{\"@type\":\"ImageObject\",\"@id\":\"https:\/\/openwebsolutions.in\/blog\/#personlogo\",\"inLanguage\":\"en-US\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/1eea674a264b13f5b7c5895e36503137?s=96&r=g\",\"caption\":\"Arindam Kundu\"}}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","_links":{"self":[{"href":"https:\/\/openwebsolutions.in\/blog\/wp-json\/wp\/v2\/posts\/1342"}],"collection":[{"href":"https:\/\/openwebsolutions.in\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/openwebsolutions.in\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/openwebsolutions.in\/blog\/wp-json\/wp\/v2\/users\/35"}],"replies":[{"embeddable":true,"href":"https:\/\/openwebsolutions.in\/blog\/wp-json\/wp\/v2\/comments?post=1342"}],"version-history":[{"count":4,"href":"https:\/\/openwebsolutions.in\/blog\/wp-json\/wp\/v2\/posts\/1342\/revisions"}],"predecessor-version":[{"id":1445,"href":"https:\/\/openwebsolutions.in\/blog\/wp-json\/wp\/v2\/posts\/1342\/revisions\/1445"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/openwebsolutions.in\/blog\/wp-json\/wp\/v2\/media\/1441"}],"wp:attachment":[{"href":"https:\/\/openwebsolutions.in\/blog\/wp-json\/wp\/v2\/media?parent=1342"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/openwebsolutions.in\/blog\/wp-json\/wp\/v2\/categories?post=1342"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/openwebsolutions.in\/blog\/wp-json\/wp\/v2\/tags?post=1342"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}