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
27
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
71
Support for HSM-like capabilities in Android
harri35
0
92
Why doesn't my in-app QR code work (on location)?
harri35
0
21
Git merge-base
harri35
1
59
Smoke testing your library
harri35
0
22
Collections in Kotlin
harri35
0
27
Data classes in Kotlin
harri35
0
20
Two-factor authentication at GDG Riga
harri35
0
62
Two-factor authentication at GDG Tartu
harri35
0
49
Other Decks in Programming
See All in Programming
単体テストを書かない技術 #phpcon_odawara
o0h
PRO
26
8.2k
ADRを一年運用してみた/adr_after_a_year
hanhan1978
7
2.4k
Milestoner
bkuhlmann
1
410
0→1と1→10の狭間で Javaという技術選定を振り返る/Reflecting on the Decision to Choose Java Between Scaling from 0 to 1 and 1 to 10
jaguar_imo
2
380
[技育CAMPアカデミア]アイディアを形に!【超入門】スマホアプリ開発〜リリースまでの流れをご紹介
teamlab
PRO
0
360
StoreKit2によるiOSのアプリ内課金のリニューアル
kangnux
0
110
AWS CDKコントリビュートTIPS / aws-cdk-contribution-tips
gotok365
2
120
新宿ダンジョンを可視化してみた
satoshi7190
2
240
スキーマ駆動開発による品質とスピードの両立 - 私達は何故、スキーマを書くのか
kentaroutakeda
0
170
From Spring Boot 2 to Spring Boot 3 with Java 22 and Jakarta EE
ivargrimstad
0
1.2k
Rethinking UI building strategies @ SFI 2024
letelete
0
270
冗長なエラーログを削減し、スタックトレースを手に入れる / Reducing Verbose Error Logs and Obtaining Stack Traces
upamune
0
510
Featured
See All Featured
ReactJS: Keep Simple. Everything can be a component!
pedronauck
659
120k
Ruby is Unlike a Banana
tanoku
96
10k
Typedesign – Prime Four
hannesfritz
36
2.1k
CSS Pre-Processors: Stylus, Less & Sass
bermonpainter
352
28k
How to train your dragon (web standard)
notwaldorf
73
5.2k
4 Signs Your Business is Dying
shpigford
175
21k
The Invisible Customer
myddelton
114
12k
CoffeeScript is Beautiful & I Never Want to Write Plain JavaScript Again
sstephenson
155
14k
Why You Should Never Use an ORM
jnunemaker
PRO
51
8.6k
The Success of Rails: Ensuring Growth for the Next 100 Years
eileencodes
30
6k
GraphQLの誤解/rethinking-graphql
sonatard
50
9.2k
Designing with Data
zakiwarfel
96
4.8k
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?