$30 off During Our Annual Pro Sale. View Details »
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
110
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
92
Kotlin Flow Application and Testing on Android
ivanw
0
310
Kotlin Flow Application and Testing on Android
ivanw
1
450
A Step-by-Step Guide to Kotlin Flow 手把手帶你認識 Kotlin Flow
ivanw
0
210
Coroutines Made Easy
ivanw
1
190
All About KotlinConf 2019
ivanw
0
130
Writing Tests in Kotlin
ivanw
0
340
Other Decks in Programming
See All in Programming
Navigation 3: 적응형 UI를 위한 앱 탐색
fornewid
1
150
CSC305 Lecture 15
javiergs
PRO
0
250
connect-python: convenient protobuf RPC for Python
anuraaga
0
360
Developing static sites with Ruby
okuramasafumi
0
160
ZOZOにおけるAI活用の現在 ~モバイルアプリ開発でのAI活用状況と事例~
zozotech
PRO
8
4.1k
WebRTC、 綺麗に見るか滑らかに見るか
sublimer
1
150
関数実行の裏側では何が起きているのか?
minop1205
1
600
複数人でのCLI/Infrastructure as Codeの暮らしを良くする
shmokmt
5
2.1k
AIエージェントを活かすPM術 AI駆動開発の現場から
gyuta
0
230
ViewファーストなRailsアプリ開発のたのしさ
sugiwe
0
400
tsgolintはいかにしてtypescript-goの非公開APIを呼び出しているのか
syumai
5
1.4k
大体よく分かるscala.collection.immutable.HashMap ~ Compressed Hash-Array Mapped Prefix-tree (CHAMP) ~
matsu_chara
1
210
Featured
See All Featured
Reflections from 52 weeks, 52 projects
jeffersonlam
355
21k
Chrome DevTools: State of the Union 2024 - Debugging React & Beyond
addyosmani
9
1k
Bash Introduction
62gerente
615
210k
Music & Morning Musume
bryan
46
7k
Rebuilding a faster, lazier Slack
samanthasiow
84
9.3k
Creating an realtime collaboration tool: Agile Flush - .NET Oxford
marcduiker
35
2.3k
How To Stay Up To Date on Web Technology
chriscoyier
791
250k
For a Future-Friendly Web
brad_frost
180
10k
Producing Creativity
orderedlist
PRO
348
40k
Evolution of real-time – Irina Nazarova, EuRuKo, 2024
irinanazarova
9
1.1k
Intergalactic Javascript Robots from Outer Space
tanoku
273
27k
Product Roadmaps are Hard
iamctodd
PRO
55
12k
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