Function Parameters and Return Values
Learn how to send information to functions and return calculated values.
Kotlin Code
Study the example and understand each part.
fun add(a: Int, b: Int): Int {
return a + b
}
fun main() {
val result = add(20, 10)
println("Result: $result")
}
Kotlin is commonly developed using Android Studio or IntelliJ IDEA. These examples can be used as a foundation for Android application development.
Key Concept
Kotlin functions can receive parameters and specify a return type after the parameter list.
Expected Output / Result
Result: 30
Finished this lesson?
Mark it complete to update your course progress.