본문 바로가기
프로그래밍 놀이터/Kotlin, Coroutine

[Effective Kotlin] Item 50: Limit the number of operations

by 돼지왕 왕돼지 2022. 6. 11.
반응형

이 글은 Effective Java 를 완독하고, Kotlin 을 상용으로 사용하는 개발자 입장에서
Effective Kotlin 글 중 새로운 내용, remind 할 필요 있는 부분, 핵심 내용 등만 추려 정리한 내용입니다.

 

#
collection 에 대한 operation 은 sequence 라 해도 heavy 할 수 있다.
따라서 다음 함수들로 복수개의 operation 을 줄여 쓸 수 있다.

filterNotNull()
mapNotNull{ }
joinToString{ }
filter{ <Predicate 1> && }
filterIsInstance()
sortedWith( compareBy({ }, { }) )
listOfNotNull(...)
filterIndexed{ index, elem -> }
// ...

 

 

Summary

 

 

반응형

댓글