Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
How to do delegation in Kotlin
Search
Sponsored
·
Ship Features Fearlessly
Turn features on and off without deploys. Used by thousands of Ruby developers.
→
Harri Kirik
February 05, 2018
Programming
46
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
Transcript
14 slides
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?
More Decks by Harri Kirik
See All by Harri Kirik
Secure programming techniques: Mobile Development Security guest lecture
harri35
0
97
Support for HSM-like capabilities in Android
harri35
0
170
Why doesn't my in-app QR code work (on location)?
harri35
0
57
Git merge-base
harri35
1
90
Smoke testing your library
harri35
0
40
Collections in Kotlin
harri35
0
46
Data classes in Kotlin
harri35
0
46
Two-factor authentication at GDG Riga
harri35
0
88
Two-factor authentication at GDG Tartu
harri35
0
68
Other Decks in Programming
See All in Programming
graphql-ruby を Spinel で速くしようとした話
mtsmfm
0
150
複数ドメインを一つのアプリに統合するFlutterの設計と運用_FlutterKaigi2026登壇資料(須永高弘)
takahirosunaga
0
190
Kawaiicon: Kubernetes, it's no longer cool, but let's secure it anyway!
barnbarn
0
130
AI Augmentation Techniques with Liberty
ivargrimstad
1
480
Next.js: The final boss of Web Performance
guaca
0
410
クラウドエージェントは、 何がそんなに便利なのか / what makes cloud agents so useful
rkaga
5
870
DroidKnights 2026 Android A2UI Jetpack Compose 기반의 안전한 AI UI 렌더링 - 박제창
itsmedreamwalker
1
230
Materialが消えた日 〜真っ白なFlutterキャンバスにRenderObjectで絵を描く〜
umigishiaoi
0
160
3回つくってわかった、 定期実行ジョブ基盤の本質情報
takai
4
3.9k
Secure Your Coding Agent Like It’s Malware (v1.5) 🇬🇧 @Code.talks 2026
richargh
0
150
AIがコードを書いてくれる時代、我々は何を確かめるのか
yosuke_furukawa
PRO
13
6k
[DroidKnights 2026] Workflow AX: From Auto-Documented Policies to E2E Testing
raeminkang
0
570
Featured
See All Featured
Typedesign – Prime Four
hannesfritz
42
3.2k
Are puppies a ranking factor?
jonoalderson
2
4.2k
Agile Actions for Facilitating Distributed Teams - ADO2019
mkilby
0
340
How to Ace a Technical Interview
jacobian
280
24k
Imperfection Machines: The Place of Print at Facebook
scottboms
270
14k
Faster Mobile Websites
deanohume
310
32k
The Power of CSS Pseudo Elements
geoffreycrofte
82
6.6k
Helping Users Find Their Own Way: Creating Modern Search Experiences
danielanewman
31
3.4k
StorybookのUI Testing Handbookを読んだ
zakiyama
31
7.1k
Building a A Zero-Code AI SEO Workflow
portentint
PRO
0
830
Creating an realtime collaboration tool: Agile Flush - .NET Oxford
marcduiker
35
2.6k
Introduction to Domain-Driven Design and Collaborative software design
baasie
1
1.1k