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
40
0
Share
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
85
Support for HSM-like capabilities in Android
harri35
0
150
Why doesn't my in-app QR code work (on location)?
harri35
0
36
Git merge-base
harri35
1
78
Smoke testing your library
harri35
0
29
Collections in Kotlin
harri35
0
37
Data classes in Kotlin
harri35
0
37
Two-factor authentication at GDG Riga
harri35
0
75
Two-factor authentication at GDG Tartu
harri35
0
57
Other Decks in Programming
See All in Programming
AlarmKitで明後日起きれるアラームアプリを作る
trickart
0
140
GitHubCopilotCLIをはじめよう.pdf
htkym
0
330
AWSはOSSをどのように 考えているのか?
akihisaikeda
0
120
AgentCore Optimizationを始めよう!
licux
3
240
20年以上続くプロダクトでも使い続けられる静的解析ツールを求めて
matsuo_atsushi
0
150
ハーネスエンジニアリングにどう向き合うか 〜ルールファイルを超えて開発プロセスを設計する〜 / How to approach harness engineering
rkaga
28
23k
When benchmarks go bad - what I learned from measuring performance wrong
hollycummins
0
390
Kubernetesを使わない環境にもCloud Nativeなデプロイを実現する / Enabling Cloud Native deployments without the complexity of Kubernetes
linyows
3
410
ハーネスエンジニアリングとは?
kinopeee
13
7k
継続的な負荷検証を目指して
pyama86
3
1.2k
Sans tests, vos agents ne sont pas fiables
nabondance
0
130
Making the RBS Parser Faster
soutaro
0
720
Featured
See All Featured
The SEO Collaboration Effect
kristinabergwall1
1
450
Java REST API Framework Comparison - PWX 2021
mraible
34
9.3k
Future Trends and Review - Lecture 12 - Web Technologies (1019888BNR)
signer
PRO
0
3.5k
Lessons Learnt from Crawling 1000+ Websites
charlesmeaden
PRO
1
1.2k
What's in a price? How to price your products and services
michaelherold
247
13k
Thoughts on Productivity
jonyablonski
76
5.2k
Measuring Dark Social's Impact On Conversion and Attribution
stephenakadiri
2
190
[SF Ruby Conf 2025] Rails X
palkan
2
1k
Beyond borders and beyond the search box: How to win the global "messy middle" with AI-driven SEO
davidcarrasco
3
130
Primal Persuasion: How to Engage the Brain for Learning That Lasts
tmiket
0
340
Helping Users Find Their Own Way: Creating Modern Search Experiences
danielanewman
31
3.2k
Easily Structure & Communicate Ideas using Wireframe
afnizarnur
194
17k
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?