Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
How to do delegation in Kotlin
Search
Harri Kirik
February 05, 2018
Programming
48
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
How to do delegation in Kotlin
5 minute talk about delegation in Kotlin programming language.
Harri Kirik
February 05, 2018
Transcript
14 slides
designing & developing for mobile Demoday, 05/02/2018 Harri Kirik, engineer
Kotlin: Delegation
Kotlin KOTLIN: DELEGATION #kotlin
Delegation pattern KOTLIN: DELEGATION #delegation
Java example KOTLIN: DELEGATION #java
KOTLIN: DELEGATION class CarBody { int getDoorCount() { return 4;
} } class Car { CarBody body; public Car(CarBody body) { this.body = body; } public int getDoorCount() { return body.getDoorCount(); } } #demoday
Kotlin example KOTLIN: DELEGATION #kotlin
The by-clause KOTLIN: DELEGATION #by-clause
KOTLIN: DELEGATION interface CarBody { fun getDoorCount(): Int } class
CarBodyImpl() : CarBody { override fun getDoorCount() = 4 } class Car(c: CarBody) : CarBody by c #demoday
KOTLIN: DELEGATION interface CarBody { fun getDoorCount(): Int } class
CarBodyImpl() : CarBody { override fun getDoorCount() = 4 } class Car(c: CarBody) : CarBody by c #demoday
KOTLIN: DELEGATION interface CarBody { fun getDoorCount(): Int } class
CarBodyImpl() : CarBody { override fun getDoorCount() = 4 } class Car(c: CarBody) : CarBody by c #demoday
KOTLIN: DELEGATION interface CarBody { fun getDoorCount(): Int } class
CarBodyImpl() : CarBody { override fun getDoorCount() = 4 } class Car(c: CarBody) : CarBody by c fun main(args: Array<String>) { val car = Car(CarBodyImpl()).getDoorCount() println(car) } #demoday
Delegated properties KOTLIN: DELEGATION #properties
KOTLIN: DELEGATION class Car { val bodyWeight: Int by CarBodyWight()
} #demoday
http:// lab.mobi designing & developing for mobile thanks Questions?
More Decks by Harri Kirik
See All by Harri Kirik
Secure programming techniques: Mobile Development Security guest lecture
harri35
0
97
Support for HSM-like capabilities in Android
harri35
0
180
Why doesn't my in-app QR code work (on location)?
harri35
0
59
Git merge-base
harri35
1
92
Smoke testing your library
harri35
0
40
Collections in Kotlin
harri35
0
47
Data classes in Kotlin
harri35
0
49
Two-factor authentication at GDG Riga
harri35
0
89
Two-factor authentication at GDG Tartu
harri35
0
69
Other Decks in Programming
See All in Programming
社内AIエージェント「Askワンバン」における コストチューニングの取り組み
t0yohei
0
180
[DroidKnights 2026] Workflow AX: From Auto-Documented Policies to E2E Testing
raeminkang
0
610
数行の変更でDockerビルドを最大91%高速化~GitLab CIの実行基盤を社内40リポジトリに展開するまで~
picopico
2
290
Beyond Chatbots: Agentic UI with Open Standards @W-JAX 2026, München
manfredsteyer
PRO
0
130
コード生成時代のAPI定義を支えるRequest Spec移行
pvcresin
0
300
祈るテストから、探索するテストへ 〜Lincheckではじめる並行処理テスト〜
yyh_gl
0
430
ビジネスロジックを堅牢に~Scala 3のドメインプリミティブ~
j5ik2o
0
230
止まらない比較を止める — 余帰納法で無限ストリームを比べる
tarao
0
210
作れるエンジニアから、価値を届けるエンジニアへ
ryunakayama
1
820
Agentic AI with the Power of Jakarta EE
ivargrimstad
0
190
[DroidKnights 2026] Workflow AX 적용기 — 자동 정책 정리부터 E2E까지
dayeon
0
120
Getting Started with Vibe Coding
miccheng
0
250
Featured
See All Featured
Bioeconomy Workshop: Dr. Julius Ecuru, Opportunities for a Bioeconomy in West Africa
akademiya2063
PRO
1
470
My Coaching Mixtape
mlcsv
0
400
Lightning Talk: Beautiful Slides for Beginners
inesmontani
PRO
2
860
Why Your Marketing Sucks and What You Can Do About It - Sophie Logan
marketingsoph
0
470
エンジニアに許された特別な時間の終わり
watany
109
250k
Statistics for Hackers
jakevdp
799
230k
Designing for Performance
lara
612
70k
The Invisible Side of Design
smashingmag
301
52k
Design and Strategy: How to Deal with People Who Don’t "Get" Design
morganepeng
133
20k
Exploring anti-patterns in Rails
aemeredith
4
580
Writing Fast Ruby
sferik
630
63k
Primal Persuasion: How to Engage the Brain for Learning That Lasts
tmiket
0
520