Class

  1. Property 선언과 initializer blocks
  2. Secondary constructors
  3. Method 선언
  4. Companion Object
class Layout() {
    // Property
    var name = "name"
    val age: Int

    // Initializer block
    init {
        age = 20
    }

    // Secondary constructors
    constructor(_name: String) : this() {
        name = _name
    }

    // Companion object
    companion object {
        private const val CONST_VAL = 5
    }
}

Naming Rules

// normal property and local variable
fun processDeclarations() { /*...*/ }
var declarationCount = 1

// Factory function
interface Foo { /*...*/ }

class FooImpl : Foo { /*...*/ }

fun Foo(): Foo { return FooImpl() }