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
How to do delegation in Kotlin
Search
Harri Kirik
February 05, 2018
Programming
42
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
More Decks by Harri Kirik
See All by Harri Kirik
Secure programming techniques: Mobile Development Security guest lecture
harri35
0
92
Support for HSM-like capabilities in Android
harri35
0
160
Why doesn't my in-app QR code work (on location)?
harri35
0
48
Git merge-base
harri35
1
87
Smoke testing your library
harri35
0
32
Collections in Kotlin
harri35
0
42
Data classes in Kotlin
harri35
0
43
Two-factor authentication at GDG Riga
harri35
0
84
Two-factor authentication at GDG Tartu
harri35
0
64
Other Decks in Programming
See All in Programming
新卒PdEのリアル
ryu1013
1
410
私のClaude Code活用法 (個人開発編) - PHPerKaigi mini #4(2026/08/24)
panda_program
1
210
AI に Inclusive UI を書かせよう — Design Rules Skill で Compose UI を作り直す
theoriatec2024
1
450
初めての模倣学習とVLA
natsutan
0
490
What We Talk About When We Talk About XP
m_seki
2
370
アクセシビリティから考える情報設計
high_g_engineer
0
230
ハーネス設計入門 〜プロンプト、コンテキストの次〜
kinopeee
54
36k
XP祭りでしか伝わらないフリップネタ #xpjug
murabayashi
0
110
型解析で実現する Go の言語内 DSL / Conference に Go! タイムテーブルの歩き方 for Gophers
mazrean
0
130
自分的「カンファレンスの楽しみ方」
syumai
0
190
XHTMLが残したもの
yosuke_furukawa
PRO
1
410
スマート反転とウェブアクセシビリティ
camiha
0
110
Featured
See All Featured
Why Our Code Smells
bkeepers
PRO
340
58k
AI: The stuff that nobody shows you
jnunemaker
PRO
9
970
Impact Scores and Hybrid Strategies: The future of link building
tamaranovitovic
0
430
Building an army of robots
kneath
306
46k
Are puppies a ranking factor?
jonoalderson
2
3.9k
CSS Pre-Processors: Stylus, Less & Sass
bermonpainter
360
30k
What’s in a name? Adding method to the madness
productmarketing
PRO
24
4.2k
Why You Should Never Use an ORM
jnunemaker
PRO
61
10k
Stop Working from a Prison Cell
hatefulcrawdad
274
21k
The Organizational Zoo: Understanding Human Behavior Agility Through Metaphoric Constructive Conversations (based on the works of Arthur Shelley, Ph.D)
kimpetersen
PRO
0
440
Leadership Guide Workshop - DevTernity 2021
reverentgeek
1
370
SERP Conf. Vienna - Web Accessibility: Optimizing for Inclusivity and SEO
sarafernandez
2
1.6k
Transcript
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?