Kotlin Scope Functions

· Kotlin
오늘은 내배캠 5주차 강의에 있는 scope function의 정의와 사용법, 사용시기 등을 정리해보려한다. 1. let - 람다의 결과를 반환 / it 사용 // 1. non-null 값에 대해서만 code block을 실행시켜야 할 때 var strNum = "10" var result = if(strNum != null) Integer.parseInt(it) else null var result = strNum?.let { // 중괄호 안에서는 it으로 활용함 Integer.parseInt(it) } // 2. 하나 이상의 call chain 결과를 호출할 때 (출력 등) val strings = listOf("APPLE", "CAR") strings.map{ it.length } .filter{ ..
탱구리몬
'Kotlin Scope Functions' 태그의 글 목록