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
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
91
Kotlin Flow Application and Testing on Android
ivanw
0
300
Kotlin Flow Application and Testing on Android
ivanw
1
450
A Step-by-Step Guide to Kotlin Flow 手把手帶你認識 Kotlin Flow
ivanw
0
200
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
FindyにおけるTakumi活用と脆弱性管理のこれから
rvirus0817
0
390
MLH State of the League: 2026 Season
theycallmeswift
0
210
ProxyによるWindow間RPC機構の構築
syumai
3
830
ECS初心者の仲間 – TUIツール「e1s」の紹介
keidarcy
0
150
開発チーム・開発組織の設計改善スキルの向上
masuda220
PRO
18
9.7k
モバイルアプリからWebへの横展開を加速した話_Claude_Code_実践術.pdf
kazuyasakamoto
0
300
TDD 実践ミニトーク
contour_gara
1
280
為你自己學 Python - 冷知識篇
eddie
1
340
OSS開発者という働き方
andpad
5
1.6k
もうちょっといいRubyプロファイラを作りたい (2025)
osyoyu
0
240
AIレビュアーをスケールさせるには / Scaling AI Reviewers
technuma
2
240
私の後悔をAWS DMSで解決した話
hiramax
4
190
Featured
See All Featured
Helping Users Find Their Own Way: Creating Modern Search Experiences
danielanewman
29
2.8k
Thoughts on Productivity
jonyablonski
69
4.8k
Facilitating Awesome Meetings
lara
55
6.5k
We Have a Design System, Now What?
morganepeng
53
7.8k
Docker and Python
trallard
45
3.5k
[RailsConf 2023 Opening Keynote] The Magic of Rails
eileencodes
30
9.6k
Creating an realtime collaboration tool: Agile Flush - .NET Oxford
marcduiker
31
2.2k
Rails Girls Zürich Keynote
gr2m
95
14k
Bash Introduction
62gerente
615
210k
Visualization
eitanlees
147
16k
CSS Pre-Processors: Stylus, Less & Sass
bermonpainter
358
30k
For a Future-Friendly Web
brad_frost
179
9.9k
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