Extension function with Kotlin | No BS Tutorials

Welcome to No BS Tutorials. Here you will get “To the Point” tutorials with no BS involved.

Saksham Khurana
Devs Life
2 min readSep 28, 2019

--

Photo by David Hellmann on Unsplash (keyword: cable)

A detailed tutorial with thourough explanation will be found on my blog.

Introduction :

As the name suggests Kotlin extension functions extend abilities of your classes by creating your own user-defined functions.

Getting Started:

  • We will create 3 different extension functions here to understand the concept
  • Create an empty file anywhere in your package (don’t make it class/interface or anything)
  • First: create a simple toast (& not writing a long line for such a simple thing)

Now simply you can call it inside your activity as

Again simply call that as

  • Third: open a website in the browser (send intent)

to open website from activity call

Conclusion

Extension functions in kotlin make your life so so easy by not repeating common tasks again and again and include them right along with the respective class itself.

Wrap Up

Once again if you wish to know in more detail about this entire tutorial visit my blog.

Thanks a lot for tuning in today, for more tutorials follow this publication or subscribe to my blog.

--

--