Skip to content

Kotlin style guide discussion #584

Description

@tomholub

Here I will leave comments about Kotlin style patterns I notice, and my proposals on which ones seem most readable. Later we will discuss and compromise on something we can both live with :)

So far I noticed:

  1. I prefer to avoid Multiline ternary operators:
// Weird
return if (condition) {
  "XXX"
} else {
  "Yyy"
}

// Good
return if (condition) "XXX" else "Yyy"
  1. empty when else should be on one line
when (cond) {
  "X" -> functionality ()
  else -> {}
}

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions