android/kotlin-guides

Using expression functions.

Closed this issue · 3 comments

The style guide says that expression functions should not wrap to two lines. But the IDE inspection suggests that even multi-line functions with a single expression should be converted to an expression function:

screen shot 2017-11-20 at 14 07 58

As you said, this is a multi-line statement but is not a statement that is being forced to wrap. Thus, it is valid as an expression body in the form

override fun convert(from: String) = when (from) {
    "N" -> ChargingStatus.Mode.NOT_CONNECTED
    ...
}

Thank you, now it's clear. Closing the issue.

Dupe #36.