Skip to content

Commit

Permalink
Rephrase definition of single-expression function
Browse files Browse the repository at this point in the history
The current definition says "When a function returns a single expression", which I don't think is correct: It sounds as if the function returns the expresions inside it.

This is an opinionated nitpick, though, so feel free to close this!
  • Loading branch information
vegarsti authored Jun 26, 2023
1 parent 2dac9b6 commit 917686f
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion docs/topics/functions.md
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ fun printHello(name: String?) { ... }

### Single-expression functions

When a function returns a single expression, the curly braces can be omitted and the body is specified after a `=` symbol:
When a function contains a single `return` expression, the curly braces can be omitted and the body is specified after a `=` symbol:

```kotlin
fun double(x: Int): Int = x * 2
Expand Down

0 comments on commit 917686f

Please sign in to comment.