Functions In Kotlin

tarun bhatt
6 min readOct 14, 2021

Functions are an essential part of any programming language

From my dev laptop

In the previous two articles, I have written on the basics of Kotlin. The focus of this article is Functions.

In Kotlin, functions do not need a class, which differs from some of the other widely used programming languages like Java, C#, etc.

It’s advisable to read my earlier articles before proceeding further.

I will be covering the following sections in this article:

  1. Function expressions
  2. Local Functions
  3. Functions with default parameters
  4. @Jvm overloads
  5. Functions with Named parameters
  6. Extension functions
  7. Inflix functions
  8. Tail recursive functions

There is a lot to cover but first, let us look at a basic function definition.

fun doSomething(value: String) : String {
return “ “
}

fun keyword defines a function, and the return keyword returns a value to the calling…

--

--

tarun bhatt
tarun bhatt

Written by tarun bhatt

Learning to write and share. #ITNerd #MentalHealthAdvocate #MenRightsActivist #ToastMaster #PublicSpeaker

No responses yet