728x90 With1 [Kotlin] 코틀린 표준 라이브러리 let(), also(), apply(), run(), with() - (3) https://thkim-study.tistory.com/6 - let() 함수 https://thkim-study.tistory.com/7 - also() 함수 코틀린 표준 라이브러리 중 apply()를 알아보자. apply()란 무엇인가 apply() 함수는 람다식 접근 방법이 this이고 반환 방법도 this이다. 또한 이전에 스터디했던 let(), also()와 다르게 람다식이 확장 함수로 처리된다. 간단한 예제를 통해 알아보자. data class Car(var name: String, var speed: Int) var car = Car("Sports Car", 100) car.apply { this.speed = 120 } println(car) val returnObj = car.apply.. 2020. 7. 22. 이전 1 다음 728x90