Skip to content

Conversation

@zamulla
Copy link
Contributor

@zamulla zamulla commented Nov 7, 2025

No description provided.

@AlexanderPrendota

This comment was marked as outdated.

@zamulla zamulla marked this pull request as ready for review November 13, 2025 11:12
@zamulla zamulla requested a review from a team as a code owner November 13, 2025 11:12
```

Such parameters are also referred to as _optional parameters_.
If a parameter with default value precedes a parameter with no default value, the default value can only be used by calling
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This sentence is a bit hard to read

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, I think it needs a bit more nuance when you have trailing lambdas

If a function does not return a useful value, its return type is `Unit` (corresponds to the `void` type in Java).

`Unit` is a type with only one value - `Unit`.
You don't have to declare this return type, or return `Unit` explicitly.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not entirely true. You still very much use Unit in functional types:

fun also(block: T.() -> Unit): T { ... }

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, I think it's important to clarify that Unit is only assumed as the return type when you use braces to define the function. Otherwise, the type is inferred to the result type of the expression.

@zamulla zamulla requested a review from serras November 13, 2025 14:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants