Coding Conventions
Coding Conventions
This page contains the current coding style for the Kotlin language.
Naming Style
If in doubt default to the Java Coding Conventions such as:
- use of camelCase for names (and avoid underscore in names)
- types start with upper case
- methods and properties start with lower case
- use 4 space indentation
- public functions should have documentation such that it appears in Kotlin Doc
Colon
There is a space before colon where colon separates type and supertype and there's no space where colon separates instance and type:
interface Foo<out T : Any> : Bar { fun foo(a: Int): T }
Lambdas
In lambda expressions, spaces should be used around the curly braces, as well as around the arrow which separates the parameters from the body. Whenever possible, a lambda sho