package com.example.complie
typealias Username = String
fun main() {
val output = Outer.Nested.grer() //내부 클래스는 객체 생성 없이 사용 가능
//Outer.outside() <- 외부 클래스는 객체 생성해야함
}
inline fun inlineLambda(a: Int, b: Int, out:(Int, Int) -> Unit){
out(a,b)
}
class Outer{
val ov = 5
class Nested{
val nv = 10 // out 변수인 ov는 불가
fun grer() = println("Hello")
som() // companion object는 사용가능
}
companion object{
const val country = "Korea"
fun som = println("Simple")
}
fun outside() = Nested().grer() //객체 생성 없이 중첩 클래스의 매서드 접근
val test:Int = Nested().nv // 객체 생성 없이 중첩 클래스 프로퍼티 접근
}
[Kotlin] forEach / for EachIndexed (0) | 2021.04.08 |
---|---|
[Kotlin] 배열 람다식 (0) | 2021.04.08 |
[Kotlin] 인터페이스, 클래스 위임 // companion object (0) | 2021.04.06 |
[Kotlin] latinit, layzy (0) | 2021.04.01 |
[Kotlin] 클래스 게터 세터 (0) | 2021.04.01 |
댓글 영역