컬렉션

앞선 포스팅에서는 코틀린에서 사용할 수 있는 컬렉션의 종류와 그 쓰임을 알아보았다면, 이를 제대로 활용하기 위해서 제공하는 다양한 함수들에 대해 알아보도록 한다.    코틀린 공식 문서에 따라 정리되었고, 그에 따르면 Collection은 다음과 같은 기능을 제공하고, 그에 따라 구현 및 가공될 수 있다 !          Iteratoriterator 는 Set 과 List 를 포함해 Iterable interface 의 상속자들로부터 가져올 수 있고, iterator() 함수 호출로 구현이 가능하다. iterator 는 첫번째 element 를 가리키고 이동가능하며, 마지막에 도달하면 다시 사용할 수 없으므로 새로 iterator 를 얻어야 한다. iteratorListIteratorMutableIt..
컬렉션은 수집이라는 단어 의미 그대로 다수의 객체를 수집해놓은 객체를 의미한다. 자바에도 컬렉션이 존재하지만, 코틀린은 그 특성 처럼 read - only, mutable interface 모두 제공한다. Note that a mutable collection doesn't have to be assigned to a var. Write operations with a mutable collection are still possible even if it is assigned to a val. The benefit of assigning mutable collections to val is that you protect the reference to the mutable collection from mo..
sxunea
'컬렉션' 태그의 글 목록