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
27
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
71
Support for HSM-like capabilities in Android
harri35
0
92
Why doesn't my in-app QR code work (on location)?
harri35
0
21
Git merge-base
harri35
1
59
Smoke testing your library
harri35
0
22
Data classes in Kotlin
harri35
0
20
How to do delegation in Kotlin
harri35
0
27
Two-factor authentication at GDG Riga
harri35
0
62
Two-factor authentication at GDG Tartu
harri35
0
49
Other Decks in Programming
See All in Programming
try! Swift Tokyo 2024のLT枠に採択されたプロポーザルを出すときに考えていたこと
ski
0
350
はてなにおける CSS Modules、及び CSS Modules に足りないもの / CSS Modules in Hatena, and CSS Modules missing parts
mizdra
6
910
Build Apps for iOS, Android & Desktop in 100% Kotlin With Compose Multiplatform (mDevCamp 2024)
zsmb
0
260
⼤規模⾔語モデルの拡張(RAG)が 終わったかも知れない件について
nearme_tech
23
15k
Behind VS Code Extensions for JavaScript / TypeScript Linnting and Formatting
unvalley
5
890
Blue/Greenデプロイの導入による 運用フローの改善
kudoas
1
370
ゆるい個人開発のススメ
kuroppe1819
10
980
#phpcon_odawara オープン・クローズドなテストフィクスチャを求めて / open closed test fixtures
77web
3
230
Compose-View Interop in Practice (mDevCamp 2024)
stewemetal
0
120
Semantic search with Django and pgvector
pauloxnet
0
240
"config" ってなんだ? / What is "config"?
okashoi
0
240
PHPの次期バージョンはこの時期どうなっているのか - Internalsの開発体制について - PHPカンファレンス小田原
youkidearitai
PRO
1
190
Featured
See All Featured
Designing Dashboards & Data Visualisations in Web Apps
destraynor
226
51k
Building Better People: How to give real-time feedback that sticks.
wjessup
355
18k
What the flash - Photography Introduction
edds
64
11k
Code Reviewing Like a Champion
maltzj
514
39k
Testing 201, or: Great Expectations
jmmastey
28
6.3k
How GitHub (no longer) Works
holman
304
140k
Easily Structure & Communicate Ideas using Wireframe
afnizarnur
187
16k
The Psychology of Web Performance [Beyond Tellerrand 2023]
tammyeverts
6
1.5k
実際に使うSQLの書き方 徹底解説 / pgcon21j-tutorial
soudai
120
39k
Agile that works and the tools we love
rasmusluckow
325
20k
Why You Should Never Use an ORM
jnunemaker
PRO
51
8.6k
How to name files
jennybc
65
93k
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?