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
Harri Kirik
April 02, 2018
Programming
0
32
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
78
Support for HSM-like capabilities in Android
harri35
0
130
Why doesn't my in-app QR code work (on location)?
harri35
0
27
Git merge-base
harri35
1
67
Smoke testing your library
harri35
0
25
Data classes in Kotlin
harri35
0
29
How to do delegation in Kotlin
harri35
0
31
Two-factor authentication at GDG Riga
harri35
0
70
Two-factor authentication at GDG Tartu
harri35
0
52
Other Decks in Programming
See All in Programming
ComposeでのPicture in Picture
takathemax
0
120
「理解」を重視したAI活用開発
fast_doctor
0
190
Do Dumb Things
mitsuhiko
0
450
Deoptimization: How YJIT Speeds Up Ruby by Slowing Down / RubyKaigi 2025
k0kubun
0
1.3k
「”誤った使い方をすることが困難”な設計」で良いコードの基礎を固めよう / phpcon-odawara-2025
taniguhey
0
170
Cursor/Devin全社導入の理想と現実
saitoryc
23
17k
一緒に働きたくなるプログラマの思想 #QiitaConference
mu_zaru
71
17k
AWS で実現する安全な AI エージェントの作り方 〜 Bedrock Engineer の実装例を添えて 〜 / how-to-build-secure-ai-agents
gawa
8
860
REALITY コマンド作成チュートリアル
nishiuriraku
0
110
Making TCPSocket.new "Happy"!
coe401_
1
1.9k
Vibe Codingをせずに Clineを使っている
watany
17
6.3k
AIコーディングの理想と現実
tomohisa
29
34k
Featured
See All Featured
How to Think Like a Performance Engineer
csswizardry
23
1.5k
Fontdeck: Realign not Redesign
paulrobertlloyd
83
5.5k
What’s in a name? Adding method to the madness
productmarketing
PRO
22
3.4k
Why Our Code Smells
bkeepers
PRO
336
57k
What's in a price? How to price your products and services
michaelherold
245
12k
CoffeeScript is Beautiful & I Never Want to Write Plain JavaScript Again
sstephenson
160
15k
Product Roadmaps are Hard
iamctodd
PRO
52
11k
Intergalactic Javascript Robots from Outer Space
tanoku
270
27k
Evolution of real-time – Irina Nazarova, EuRuKo, 2024
irinanazarova
8
670
Making Projects Easy
brettharned
116
6.1k
Statistics for Hackers
jakevdp
798
220k
Facilitating Awesome Meetings
lara
54
6.3k
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?