Shorthand Functions

suggest change

If a function contains just one expression, we can omit the brace brackets and use an equals instead, like a variable assignment. The result of the expression is returned automatically.

fun sayMyName(name: String): String = "Your name is $name"

Feedback about page:

Feedback:
Optional: your email if you want me to get back to you:



Table Of Contents