Book Image

Programming Kotlin

Book Image

Programming Kotlin

Overview of this book

Quickly learn the fundamentals of the Kotlin language and see it in action on the web. Easy to follow and covering the full set of programming features, this book will get you fluent in Kotlin for Android.
Table of Contents (20 chapters)
Programming Kotlin
Credits
About the Authors
About the Reviewers
www.PacktPub.com
Customer Feedback
Preface

Class hierarchy


Like Scala, Kotlin distinguishes between mutable and immutable collections. A mutable collection can be updated in place by adding, removing or replacing an element, and it will be reflected in its state. On the other side, an immutable collection, while it provides the same operations-addition, removal, or replacement-via the operator functions will end up producing a brand-new collection, leaving the initial one untouched. You will see later in this chapter how immutability is achieved through interface definition; at runtime, the implementations relies on Java's mutable collections.

Unlike Scala, Kotlin's makers have decided to avoid having two separate namespaces for each collection mode. You will find all the collections in the kotlin.collections namespace.

In the following figure, you will see the Kotlin collections class diagram. All mutable types can be easily identified since they carry the prefix Mutable. All of following types are parameterized. One thing to notice...