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
Sponsored
·
SiteGround - Reliable hosting with speed, security, and support you can count on.
→
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
83
Support for HSM-like capabilities in Android
harri35
0
140
Why doesn't my in-app QR code work (on location)?
harri35
0
33
Git merge-base
harri35
1
73
Smoke testing your library
harri35
0
28
Collections in Kotlin
harri35
0
36
Data classes in Kotlin
harri35
0
34
Two-factor authentication at GDG Riga
harri35
0
74
Two-factor authentication at GDG Tartu
harri35
0
57
Other Decks in Programming
See All in Programming
humanlayerのブログから学ぶ、良いCLAUDE.mdの書き方
tsukamoto1783
0
200
Basic Architectures
denyspoltorak
0
680
Smart Handoff/Pickup ガイド - Claude Code セッション管理
yukiigarashi
0
140
Architectural Extensions
denyspoltorak
0
300
登壇資料を作る時に意識していること #登壇資料_findy
konifar
4
1.6k
組織で育むオブザーバビリティ
ryota_hnk
0
180
16年目のピクシブ百科事典を支える最新の技術基盤 / The Modern Tech Stack Powering Pixiv Encyclopedia in its 16th Year
ahuglajbclajep
5
1k
並行開発のためのコードレビュー
miyukiw
0
330
CSC307 Lecture 05
javiergs
PRO
0
500
Claude Codeと2つの巻き戻し戦略 / Two Rewind Strategies with Claude Code
fruitriin
0
140
AI時代のキャリアプラン「技術の引力」からの脱出と「問い」へのいざない / tech-gravity
minodriven
21
7.4k
Patterns of Patterns
denyspoltorak
0
1.4k
Featured
See All Featured
Leveraging Curiosity to Care for An Aging Population
cassininazir
1
160
Raft: Consensus for Rubyists
vanstee
141
7.3k
The Curious Case for Waylosing
cassininazir
0
240
Bioeconomy Workshop: Dr. Julius Ecuru, Opportunities for a Bioeconomy in West Africa
akademiya2063
PRO
1
55
Game over? The fight for quality and originality in the time of robots
wayneb77
1
120
Fashionably flexible responsive web design (full day workshop)
malarkey
408
66k
RailsConf 2023
tenderlove
30
1.3k
10 Git Anti Patterns You Should be Aware of
lemiorhan
PRO
659
61k
Why You Should Never Use an ORM
jnunemaker
PRO
61
9.7k
30 Presentation Tips
portentint
PRO
1
220
Leo the Paperboy
mayatellez
4
1.4k
Documentation Writing (for coders)
carmenintech
77
5.3k
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?