티스토리 뷰

공부

[kotlin] `list` to `map` {key: index}

승가비 2022. 8. 9. 23:22
728x90
IntStream.range(0, alphabet.size())
         .boxed()
         .collect(toMap(alphabet::get, i -> i));

https://stackoverflow.com/questions/33138577/how-to-convert-list-to-map-with-indexes-using-stream-java-8

 

How to convert List to Map with indexes using stream - Java 8?

I've created method whih numerating each character of alphabet. I'm learning streams(functional programming) and try to use them as often as possible, but I don't know how to do it in this case: p...

stackoverflow.com

 

728x90
댓글