Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Collections in Kotlin
Search
Sponsored
·
Ship Features Fearlessly
Turn features on and off without deploys. Used by thousands of Ruby developers.
→
Harri Kirik
April 02, 2018
Programming
0
36
Collections in Kotlin
5-minute talk about collections in Kotlin
Harri Kirik
April 02, 2018
Tweet
Share
More Decks by Harri Kirik
See All by Harri Kirik
Secure programming techniques: Mobile Development Security guest lecture
harri35
0
83
Support for HSM-like capabilities in Android
harri35
0
140
Why doesn't my in-app QR code work (on location)?
harri35
0
33
Git merge-base
harri35
1
73
Smoke testing your library
harri35
0
28
Data classes in Kotlin
harri35
0
34
How to do delegation in Kotlin
harri35
0
37
Two-factor authentication at GDG Riga
harri35
0
74
Two-factor authentication at GDG Tartu
harri35
0
57
Other Decks in Programming
See All in Programming
Package Management Learnings from Homebrew
mikemcquaid
0
230
CSC307 Lecture 03
javiergs
PRO
1
490
CSC307 Lecture 02
javiergs
PRO
1
780
Basic Architectures
denyspoltorak
0
680
Fragmented Architectures
denyspoltorak
0
160
CSC307 Lecture 06
javiergs
PRO
0
690
Unicodeどうしてる? PHPから見たUnicode対応と他言語での対応についてのお伺い
youkidearitai
PRO
1
2.5k
CSC307 Lecture 01
javiergs
PRO
0
690
AIエージェントのキホンから学ぶ「エージェンティックコーディング」実践入門
masahiro_nishimi
5
460
Fluid Templating in TYPO3 14
s2b
0
130
LLM Observabilityによる 対話型音声AIアプリケーションの安定運用
gekko0114
2
430
Vibe Coding - AI 驅動的軟體開發
mickyp100
0
180
Featured
See All Featured
Writing Fast Ruby
sferik
630
62k
Marketing to machines
jonoalderson
1
4.6k
Git: the NoSQL Database
bkeepers
PRO
432
66k
Redefining SEO in the New Era of Traffic Generation
szymonslowik
1
220
What the history of the web can teach us about the future of AI
inesmontani
PRO
1
430
Faster Mobile Websites
deanohume
310
31k
Java REST API Framework Comparison - PWX 2021
mraible
34
9.1k
How Fast Is Fast Enough? [PerfNow 2025]
tammyeverts
3
450
The SEO Collaboration Effect
kristinabergwall1
0
350
The Cult of Friendly URLs
andyhume
79
6.8k
A brief & incomplete history of UX Design for the World Wide Web: 1989–2019
jct
1
300
Imperfection Machines: The Place of Print at Facebook
scottboms
269
14k
Transcript
designing & developing for mobile Demoday, 05/03/2018 Harri Kirik, engineer
Kotlin: Collections
Kotlin KOTLIN: COLLECTIONS #kotlin
Mutable and immutable KOTLIN: COLLECTIONS #collections
Autogenerated: 1. equals()/hashCode() pair 2. toString() 3. componentN() functions 4.
copy() function KOTLIN: COLLECTIONS #collections
KOTLIN: COLLECTIONS val numbers: MutableList<Int> = mutableListOf(1, 2, 3) val
readOnlyView: List<Int> = numbers println(numbers) // prints "[1, 2, 3]" numbers.add(4) println(readOnlyView) // prints "[1, 2, 3, 4]" readOnlyView.clear() // -> does not compile val strings = hashSetOf("a", "b", "c", "c") assert(strings.size == 3) #demoday
No dedicated syntax KOTLIN: COLLECTIONS #collections
listOf(), mutableListOf(), setOf(), mutableSetOf() KOTLIN: COLLECTIONS #collections
KOTLIN: COLLECTIONS val mutable = mutableListOf(1, 2, 3) val snapshot
= mutable.toList() mutable.add(4) println(mutable) // prints "[1, 2, 3, 4]" println(snapshot) // prints "[1, 2, 3]" #demoday
KOTLIN: COLLECTIONS val mutable = mutableListOf(1, 2, 3) val snapshot
= mutable.toList() snapshot.add(4) // Will not compile! val snapshot2 = snapshot.plus(4) // Returns a new list println(snapshot2 ) // prints "[1, 2, 3, 4]" #demoday
http:// lab.mobi designing & developing for mobile thanks Questions?