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
120
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
110
Kotlin Flow Application and Testing on Android
ivanw
0
320
Kotlin Flow Application and Testing on Android
ivanw
1
470
A Step-by-Step Guide to Kotlin Flow 手把手帶你認識 Kotlin Flow
ivanw
0
230
Coroutines Made Easy
ivanw
1
200
All About KotlinConf 2019
ivanw
0
130
Writing Tests in Kotlin
ivanw
0
360
Other Decks in Programming
See All in Programming
Migrations : C'est une question d'hygiène !
vinceamstoutz
0
1.8k
tsserverとは何だったのか、これからどうなるのか
nowaki28
1
380
AI時代になぜ書くのか
mutsumix
0
450
誰も頼んでない機能を出荷した話
zekutax
0
140
CLIであることを活かしたGitHub Copilot CLI活用術 / GitHub Copilot CLI Pro Tips & Tricks
nao_mk2
1
1k
UaaL×Androidアプリのメモリ計測 — Memory Profilerの先へ
rio432
0
180
Are We Really Coding 10× Faster with AI?
kohzas
0
230
AIチームを指揮するOSS「TAKT」活用術 / How to Use “TAKT,” an OSS Tool for Orchestrating AI Teams
nrslib
5
660
サーバーレスで作る、動画データ管理基盤
oyasumipants
0
260
AIエージェントと協働するCLI開発 — BunとOpenClawで学んだこと
yoshikouki
1
210
プラグインで拡張される Context をtype-safe にする難しさと設計判断
kazupon
2
300
oxlintはeslint/typescript-eslintを置き換えられるのか
shomafujita
2
220
Featured
See All Featured
Test your architecture with Archunit
thirion
1
2.2k
Learning to Love Humans: Emotional Interface Design
aarron
275
41k
Paper Plane
katiecoart
PRO
1
50k
Become a Pro
speakerdeck
PRO
31
5.9k
How Software Deployment tools have changed in the past 20 years
geshan
0
34k
Agile Leadership in an Agile Organization
kimpetersen
PRO
0
150
Amusing Abliteration
ianozsvald
1
180
Jamie Indigo - Trashchat’s Guide to Black Boxes: Technical SEO Tactics for LLMs
techseoconnect
PRO
0
140
<Decoding/> the Language of Devs - We Love SEO 2024
nikkihalliwell
1
220
[RailsConf 2023 Opening Keynote] The Magic of Rails
eileencodes
31
10k
RailsConf 2023
tenderlove
30
1.4k
Statistics for Hackers
jakevdp
799
230k
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