Skip to Main Content
Hands-On Data Structures and Algorithms with Kotlin
book

Hands-On Data Structures and Algorithms with Kotlin

by Chandra Sekhar Nayak, Rivu Chakraborty
February 2019
Intermediate to advanced content levelIntermediate to advanced
220 pages
5h 40m
English
Packt Publishing
Content preview from Hands-On Data Structures and Algorithms with Kotlin

The beauty of immutable arrays

Immutability is one of the key principles of modern programming languages. So, it's obvious that Kotlin also has immutability implementation. Because of this, Kotlin's collections package has treated immutable data structures as first-class citizens. A few examples might make you understand this more:

val days = listOf("Sunday", "Monday", "Tuesday", "Wednesday")val months = arrayListOf("January", "February", "March", "April")

In the preceding snippet, days is an immutable list whereas months is a mutable one. For example, months.add("May") is a valid statement whereas we cannot add an item to the days list. The only way to do so is to get a new list out of the existing one by adding the new item. Here's the ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Learn Data Structures and Algorithms with Golang

Learn Data Structures and Algorithms with Golang

Bhagvan Kommadi
Functional Programming in Kotlin

Functional Programming in Kotlin

Runar Bjarnason, Paul Chiusano, Marco Vermeulen

Publisher Resources

ISBN: 9781788994019Supplemental Content