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
Sponsored
·
Your Podcast. Everywhere. Effortlessly.
Share. Educate. Inspire. Entertain. You do you. We'll handle the rest.
→
Ivan
May 03, 2019
Programming
110
0
Share
Using Kotlin in Android
Kotlin examples for study group in Taiwan Kotlin User Group
Ivan
May 03, 2019
More Decks by Ivan
See All by Ivan
KtRssReader 的奇幻旅程
ivanw
0
99
Kotlin Flow Application and Testing on Android
ivanw
0
320
Kotlin Flow Application and Testing on Android
ivanw
1
460
A Step-by-Step Guide to Kotlin Flow 手把手帶你認識 Kotlin Flow
ivanw
0
220
Coroutines Made Easy
ivanw
1
190
All About KotlinConf 2019
ivanw
0
130
Writing Tests in Kotlin
ivanw
0
350
Other Decks in Programming
See All in Programming
ネイティブアプリとWebフロントエンドのAPI通信ラッパーにおける共通化の勘所
suguruooki
0
230
Tamach-sre-3_ANDPAD-shimaison93
mane12yurks38
0
240
Redox OS でのネームスペース管理と chroot の実現
isanethen
0
500
Laravel Nightwatchの裏側 - Laravel公式Observabilityツールを支える設計と実装
avosalmon
1
300
Smarter Angular mit Transformers.js & Prompt API
christianliebel
PRO
1
110
S3ストレージクラスの「見える」「ある」「使える」は全部違う ─ 体験から見た、仕様の深淵を覗く
ya_ma23
0
1.2k
AI活用のコスパを最大化する方法
ochtum
0
370
CS教育のDX AIによる育成の効率化
niftycorp
PRO
0
180
実践ハーネスエンジニアリング #MOSHTech
kajitack
7
5.4k
Rethinking API Platform Filters
vinceamstoutz
0
5.2k
Agentic AI: Evolution oder Revolution
mobilelarson
PRO
0
230
L’IA au service des devs : Anatomie d'un assistant de Code Review
toham
0
180
Featured
See All Featured
What’s in a name? Adding method to the madness
productmarketing
PRO
24
4k
Jess Joyce - The Pitfalls of Following Frameworks
techseoconnect
PRO
1
120
Designing for humans not robots
tammielis
254
26k
A Soul's Torment
seathinner
5
2.6k
Art, The Web, and Tiny UX
lynnandtonic
304
21k
Leveraging Curiosity to Care for An Aging Population
cassininazir
1
210
Into the Great Unknown - MozCon
thekraken
40
2.3k
Visualization
eitanlees
150
17k
Building AI with AI
inesmontani
PRO
1
840
The browser strikes back
jonoalderson
0
870
Agile Actions for Facilitating Distributed Teams - ADO2019
mkilby
0
160
GraphQLとの向き合い方2022年版
quramy
50
14k
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