Notice
Recent Posts
Recent Comments
올해는 머신러닝이다.
코틀린에서 list 를 map 으로 빠르게 변경하기 본문
You have two choices:
The first and most performant is to use associateBy
function that takes two lambdas for generating the key and value, and inlines the creation of the map:
val map = friends.associateBy({it.facebookId}, {it.points})
The second, less performant, is to use the standard map
function to create a list of Pair
which can be used by toMap
to generate the final map:
val map = friends.map { it.facebookId to it.points }.toMap()
캬 멋집니다~
'링크모음 > 코틀린' 카테고리의 다른 글
list(추가 불가능함)에 add 를 달아보자 (0) | 2018.01.06 |
---|---|
코틀린 Parcelable 추가 방법 (새롭게 추가된 방법) (0) | 2017.12.28 |
코틀린 키워드 모음 (0) | 2017.12.04 |
Sealed class + when 자세한 설명 (0) | 2017.11.21 |
접근 제어자 관련 링크 (0) | 2017.11.20 |