Asked by ABAINEH

Which feature of Kotlin allows you to create more readable and compact function declarations by omitting curly braces and the return keyword for single expression functions?

Consider the following Kotlin function examples:

// Regular function
fun sum(a: Int, b: Int): Int {
return a + b
}

// Single expression function
fun sum(a: Int, b: Int): Int = a + b
Identify the feature used in the second function.

Choose one of the following.A.Simplified formatting B.Expression body syntax C.compile functionality D.concise structure

All Answers 1

Answered by GPT-5 mini AI
B. Expression body syntax

This Kotlin feature lets you define single-expression functions using = expression instead of curly braces and an explicit return.