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
0
37
How to do delegation in Kotlin
5 minute talk about delegation in Kotlin programming language.
Harri Kirik
February 05, 2018
Tweet
Share
More Decks by Harri Kirik
See All by Harri Kirik
Secure programming techniques: Mobile Development Security guest lecture
harri35
0
81
Support for HSM-like capabilities in Android
harri35
0
130
Why doesn't my in-app QR code work (on location)?
harri35
0
31
Git merge-base
harri35
1
72
Smoke testing your library
harri35
0
26
Collections in Kotlin
harri35
0
35
Data classes in Kotlin
harri35
0
33
Two-factor authentication at GDG Riga
harri35
0
74
Two-factor authentication at GDG Tartu
harri35
0
55
Other Decks in Programming
See All in Programming
オフライン対応!Flutterアプリに全文検索エンジンを実装する @FlutterKaigi2025
itsmedreamwalker
2
220
CloudNative Days Winter 2025: 一週間で作る低レイヤコンテナランタイム
ternbusty
7
1.5k
仕様がそのままテストになる!Javaで始める振る舞い駆動開発
ohmori_yusuke
8
4.5k
自動テストを活かすためのテスト分析・テスト設計の進め方/JaSST25 Shikoku
goyoki
3
700
カンファレンス遠征を(安く)楽しむ技術
wp_daisuke
0
170
Feature Flags Suck! - KubeCon Atlanta 2025
phodgson
0
140
AI駆動開発ライフサイクル(AI-DLC)のホワイトペーパーを解説
swxhariu5
0
1.1k
目的で駆動する、AI時代のアーキテクチャ設計 / purpose-driven-architecture
minodriven
7
2.5k
関数の挙動書き換える
takatofukui
4
720
Java_プロセスのメモリ監視の落とし穴_NMT_で見抜けない_glibc_キャッシュ問題_.pdf
ntt_dsol_java
0
210
CSC509 Lecture 10
javiergs
PRO
0
180
Register is more than clipboard
satorunooshie
1
480
Featured
See All Featured
I Don’t Have Time: Getting Over the Fear to Launch Your Podcast
jcasabona
34
2.5k
Done Done
chrislema
186
16k
Designing for humans not robots
tammielis
254
26k
The Art of Programming - Codeland 2020
erikaheidi
56
14k
A better future with KSS
kneath
239
18k
Raft: Consensus for Rubyists
vanstee
140
7.2k
Java REST API Framework Comparison - PWX 2021
mraible
34
9k
Performance Is Good for Brains [We Love Speed 2024]
tammyeverts
12
1.3k
Designing Dashboards & Data Visualisations in Web Apps
destraynor
231
54k
GitHub's CSS Performance
jonrohan
1032
470k
It's Worth the Effort
3n
187
28k
Optimising Largest Contentful Paint
csswizardry
37
3.5k
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?