Expression in Kotlin

If Java i++has an expression, but i++;is an expression operator, and semicolons (;) are optional in Kotlin, an i++expression or expression in Kotlin?

+4
source share
1 answer

i++ is an expression because it has a value that you can assign to a variable, pass as an argument to a method, etc.

If you simply have i++and do nothing with its value, you use it as an instruction, that is, only for its side effects, and not for its value.

+4
source

Source: https://habr.com/ru/post/1680544/


All Articles