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
76
Support for HSM-like capabilities in Android
harri35
0
120
Why doesn't my in-app QR code work (on location)?
harri35
0
26
Git merge-base
harri35
1
66
Smoke testing your library
harri35
0
24
Data classes in Kotlin
harri35
0
27
How to do delegation in Kotlin
harri35
0
31
Two-factor authentication at GDG Riga
harri35
0
69
Two-factor authentication at GDG Tartu
harri35
0
52
Other Decks in Programming
See All in Programming
Linux && Docker 研修/Linux && Docker training
forrep
23
4.5k
SwiftUI Viewの責務分離
elmetal
PRO
0
140
Amazon ECS とマイクロサービスから考えるシステム構成
hiyanger
2
490
Unity Android XR入門
sakutama_11
0
140
CloudNativePGがCNCF Sandboxプロジェクトになったぞ! 〜CloudNativePGの仕組みの紹介〜
nnaka2992
0
220
Amazon Bedrock Multi Agentsを試してきた
tm2
1
280
[JAWS-UG横浜 #79] re:Invent 2024 の DB アップデートは Multi-Region!
maroon1st
1
140
法律の脱レガシーに学ぶフロントエンド刷新
oguemon
5
730
“あなた” の開発を支援する AI エージェント Bedrock Engineer / introducing-bedrock-engineer
gawa
11
1.8k
Conform を推す - Advocating for Conform
mizoguchicoji
3
680
JavaScriptツール群「UnJS」を5分で一気に駆け巡る!
k1tikurisu
10
1.8k
SpringBoot3.4の構造化ログ #kanjava
irof
2
970
Featured
See All Featured
jQuery: Nuts, Bolts and Bling
dougneiner
63
7.6k
A Philosophy of Restraint
colly
203
16k
No one is an island. Learnings from fostering a developers community.
thoeni
21
3.1k
Building Your Own Lightsaber
phodgson
104
6.2k
Rebuilding a faster, lazier Slack
samanthasiow
79
8.8k
Code Review Best Practice
trishagee
66
17k
Chrome DevTools: State of the Union 2024 - Debugging React & Beyond
addyosmani
3
310
Gamification - CAS2011
davidbonilla
80
5.1k
A Modern Web Designer's Workflow
chriscoyier
693
190k
What’s in a name? Adding method to the madness
productmarketing
PRO
22
3.3k
Why You Should Never Use an ORM
jnunemaker
PRO
55
9.2k
4 Signs Your Business is Dying
shpigford
182
22k
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?