Kotlin mutable interface

    [Kotlin Collection] Kotlin Mutable과 Immutable의 차이는 무엇인가? Mutable Interface의 관점에서 보는 코틀린의 가변성과 불변성

    개요 Kotlin의 Collection은 두가지 타입의 Interface를 제공한다. 한 가지는 변경 불가능(Immutable)한 Interface 이며 다른 하나는 변경 가능(Mutable)한 Interface이다. 더욱 자세히 들어가면 Immutable Interface와 Mutable Interface는 아래 [그림1]과 같은 상속 구조를 가진다. Immutable Interface에서는 값을 변경할 수 있는 함수를 제공하지 않으며, Immutable Interface를 확장하는 Mutable Interface에서 값을 변경하는 메서드를 제공한다. 필요성 Kotlin에서 이렇게 Immutable Interface와 Mutable Interface를 나눈 것은 코드 레벨에서 명확성과 안정성을 제공하기..