To Lecture Notes

IT 372 -- May 6, 2026

Review Exercises

  1. Write this function as a lambda function and test it.
    fun add(n : Int, m : Int) : Int {
        return n + m;
    }
    
    Answer:
    fun main() {
        var add : (Int, Int) -> Int = { n, m -> n + n }
        println(add(5, 7))
    }
    
  2. What does it mean in a Kotlin lambda function?
    Answer: it is used to represent the parameter of a one-parameter function. The lambda function
    var makeGreeting : (String) -> String = 
        { name -> "Hello, $name, how are you? }
    
    can be simplified to
    var makeGreeting : (String) -> String = 
        { "Hello, $it, how are you?" }
    

Introduction to Jetpack Compose

JetPack Compose Examples

Composable Parameters