Leverage Kotlin Functions & Lambdas

May 22 2024 · Kotlin 1.9.24, Android 14, Kotlin Playground

Lesson 01: Create Functions

Demo

Episode complete

Play next episode

Next

Heads up... You’re accessing parts of this content for free, with some sections shown as obfuscated text.

Heads up... You’re accessing parts of this content for free, with some sections shown as obfuscated text.

Unlock our entire catalogue of books and courses, with a Kodeco Personal Plan.

Unlock now

In this demo, you’ll learn how to create a custom function and call it from your code. You’ll be using Kotlin Playground to edit and run the code. To follow along, go to https://play.kotlinlang.org/, or fire up your browser and type Kotlin Playground in the search bar. The first link should take you to the Kotlin Playground.

fun findSquareRoot() {
  val squareRoot = sqrt(289.00)
  println("Square root is $squareRoot")
}
fun main() {
  findSquareRoot()
}
import kotlin.math.sqrt

fun main() {
  findSquareRoot()
}
fun main() {
  val result = findSquareRoot()
  println("result is $result")
}
result is kotlin.Unit
See forum comments
Cinema mode Download course materials from Github
Previous: Instruction Next: Conclusion