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
34
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
39
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
へんな働き方
yusukebe
4
2.6k
安いハードウェアでVulkan
fadis
0
520
AI Assistants for Your Angular Solutions
manfredsteyer
PRO
0
150
生成 AI 時代のスナップショットテストってやつを見せてあげますよ(α版)
ojun9
0
260
Docコメントで始める簡単ガードレール
keisukeikeda
1
130
DevinとClaude Code、SREの現場で使い倒してみた件
karia
1
1.1k
Everything Claude Code OSS詳細 — 5層構造の中身と導入方法
targe
0
130
S3ストレージクラスの「見える」「ある」「使える」は全部違う ─ 体験から見た、仕様の深淵を覗く
ya_ma23
0
740
LangChain4jとは一味違うLangChain4j-CDI
kazumura
1
200
grapheme_strrev関数が採択されました(あと雑感)
youkidearitai
PRO
1
230
Symfony + NelmioApiDocBundle を使った スキーマ駆動開発 / Schema Driven Development with NelmioApiDocBundle
okashoi
0
170
ふつうのRubyist、ちいさなデバイス、大きな一年 / Ordinary Rubyists, Tiny Devices, Big Year
chobishiba
1
480
Featured
See All Featured
State of Search Keynote: SEO is Dead Long Live SEO
ryanjones
0
160
Reflections from 52 weeks, 52 projects
jeffersonlam
356
21k
Design of three-dimensional binary manipulators for pick-and-place task avoiding obstacles (IECON2024)
konakalab
0
380
jQuery: Nuts, Bolts and Bling
dougneiner
65
8.4k
Navigating the moral maze — ethical principles for Al-driven product design
skipperchong
2
290
Understanding Cognitive Biases in Performance Measurement
bluesmoon
32
2.8k
How to Ace a Technical Interview
jacobian
281
24k
Making the Leap to Tech Lead
cromwellryan
135
9.8k
The #1 spot is gone: here's how to win anyway
tamaranovitovic
2
990
From π to Pie charts
rasagy
0
150
Documentation Writing (for coders)
carmenintech
77
5.3k
Measuring Dark Social's Impact On Conversion and Attribution
stephenakadiri
1
160
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?