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
32
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
79
Support for HSM-like capabilities in Android
harri35
0
130
Why doesn't my in-app QR code work (on location)?
harri35
0
28
Git merge-base
harri35
1
69
Smoke testing your library
harri35
0
25
Collections in Kotlin
harri35
0
33
Data classes in Kotlin
harri35
0
31
Two-factor authentication at GDG Riga
harri35
0
71
Two-factor authentication at GDG Tartu
harri35
0
53
Other Decks in Programming
See All in Programming
C++20 射影変換
faithandbrave
0
530
プロダクト志向なエンジニアがもう一歩先の価値を目指すために意識したこと
nealle
0
110
5つのアンチパターンから学ぶLT設計
narihara
1
110
Systèmes distribués, pour le meilleur et pour le pire - BreizhCamp 2025 - Conférence
slecache
0
100
deno-redisの紹介とJSRパッケージの運用について (toranoana.deno #21)
uki00a
0
150
コードの90%をAIが書く世界で何が待っているのか / What awaits us in a world where 90% of the code is written by AI
rkaga
46
31k
「ElixirでIoT!!」のこれまでとこれから
takasehideki
0
370
型付きアクターモデルがもたらす分散シミュレーションの未来
piyo7
0
810
Blazing Fast UI Development with Compose Hot Reload (droidcon New York 2025)
zsmb
1
210
Azure AI Foundryではじめてのマルチエージェントワークフロー
seosoft
0
130
Bytecode Manipulation 으로 생산성 높이기
bigstark
2
380
Google Agent Development Kit でLINE Botを作ってみた
ymd65536
2
180
Featured
See All Featured
Design and Strategy: How to Deal with People Who Don’t "Get" Design
morganepeng
130
19k
Distributed Sagas: A Protocol for Coordinating Microservices
caitiem20
331
22k
Art, The Web, and Tiny UX
lynnandtonic
299
21k
Making Projects Easy
brettharned
116
6.3k
Building an army of robots
kneath
306
45k
The Invisible Side of Design
smashingmag
299
51k
Product Roadmaps are Hard
iamctodd
PRO
54
11k
Building a Modern Day E-commerce SEO Strategy
aleyda
42
7.3k
GitHub's CSS Performance
jonrohan
1031
460k
What's in a price? How to price your products and services
michaelherold
246
12k
Designing Dashboards & Data Visualisations in Web Apps
destraynor
231
53k
BBQ
matthewcrist
89
9.7k
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?