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
Using Kotlin in Android
Search
Ivan
May 03, 2019
Programming
0
100
Using Kotlin in Android
Kotlin examples for study group in Taiwan Kotlin User Group
Ivan
May 03, 2019
Tweet
Share
More Decks by Ivan
See All by Ivan
KtRssReader 的奇幻旅程
ivanw
0
80
Kotlin Flow Application and Testing on Android
ivanw
0
290
Kotlin Flow Application and Testing on Android
ivanw
1
420
A Step-by-Step Guide to Kotlin Flow 手把手帶你認識 Kotlin Flow
ivanw
0
190
Coroutines Made Easy
ivanw
1
180
All About KotlinConf 2019
ivanw
0
120
Writing Tests in Kotlin
ivanw
0
330
Other Decks in Programming
See All in Programming
RubyLSPのマルチバイト文字対応
notfounds
0
120
macOS でできる リアルタイム動画像処理
biacco42
9
2.4k
Duckdb-Wasmでローカルダッシュボードを作ってみた
nkforwork
0
140
エンジニアとして関わる要件と仕様(公開用)
murabayashi
0
310
EMになってからチームの成果を最大化するために取り組んだこと/ Maximize team performance as EM
nashiusagi
0
100
「今のプロジェクトいろいろ大変なんですよ、app/services とかもあって……」/After Kaigi on Rails 2024 LT Night
junk0612
5
2.2k
Functional Event Sourcing using Sekiban
tomohisa
0
110
광고 소재 심사 과정에 AI를 도입하여 광고 서비스 생산성 향상시키기
kakao
PRO
0
180
AI時代におけるSRE、 あるいはエンジニアの生存戦略
pyama86
6
1.2k
ヤプリ新卒SREの オンボーディング
masaki12
0
130
受け取る人から提供する人になるということ
little_rubyist
0
250
rails new flags - `rails new` のフラグから Rails を構成するコンポーネントの変遷をザックリ眺める
snaka
0
1.8k
Featured
See All Featured
Designing Dashboards & Data Visualisations in Web Apps
destraynor
229
52k
A Tale of Four Properties
chriscoyier
156
23k
The Web Performance Landscape in 2024 [PerfNow 2024]
tammyeverts
0
120
実際に使うSQLの書き方 徹底解説 / pgcon21j-tutorial
soudai
169
50k
Docker and Python
trallard
40
3.1k
Mobile First: as difficult as doing things right
swwweet
222
8.9k
A designer walks into a library…
pauljervisheath
204
24k
Fashionably flexible responsive web design (full day workshop)
malarkey
405
65k
ピンチをチャンスに:未来をつくるプロダクトロードマップ #pmconf2020
aki_iinuma
109
49k
The Cult of Friendly URLs
andyhume
78
6k
Designing on Purpose - Digital PM Summit 2013
jponch
115
7k
Being A Developer After 40
akosma
87
590k
Transcript
Using Kotlin in Android Ivan W.
Outline • Null Safety • Data Class • Default Argument
/ Implementation 2
Null Safety • Eliminate the danger of null references from
code • Nullable types and Non-Null Types var a: String = "abc" a = null // compilation error var b: String? = "abc" b = null // ok 3 Nullable types Non-Null types
Example 1 4 Bundle args = getArguments(); if (args !=
null) { Bundle data = args.getBundle(KEY_DATA); if (data != null) { Log.d(TAG, data.getString(KEY_NAME)); } } Java
Example 1 5 Bundle args = getArguments(); if (args !=
null) { Bundle data = args.getBundle(KEY_DATA); if (data != null) { Log.d(TAG, data.getString(KEY_NAME)); } } Log.d(TAG, arguments?.getBundle(KEY_DATA)?.getString(KEY_NAME)) Java Kotlin
Data Class • It automatically generates ◦ equals() / hashCode()
◦ getters and setters ◦ toString() ◦ copy()
Example 2 7 Java Kotlin See example See example
Default Argument / Implementation 8 • Java overloads can be
replaced with one function in Kotlin
Example 3 9 private void sendInfo(String content, long Time, String
tag) { /* ... */ } private void sendInfo(String content, long Time) { /* ... */ } private void sendInfo(String content, String tag) { /* ... */ } private void sendInfo(String content) { /* ... */ } Java
Example 3 10 private fun sendInfo( content: String, time: Long
= Date().time, tag: String = TAG ) { … } sendInfo("content", time = Date().time) Kotlin
Example 4 11 Java Kotlin See example See example
Thank you! 12