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
Kotlin Null-Safety機構について
Search
Sponsored
·
Your Podcast. Everywhere. Effortlessly.
Share. Educate. Inspire. Entertain. You do you. We'll handle the rest.
→
Taro Nagasawa
November 09, 2013
Programming
2.4k
3
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Kotlin Null-Safety機構について
JJUG CCC 2013 Fallで発表した資料
Taro Nagasawa
November 09, 2013
More Decks by Taro Nagasawa
See All by Taro Nagasawa
Android開発者のための Kotlin Multiplatform入門
ntaro
0
1.8k
Kotlin 最新動向2022 #tfcon #techfeed
ntaro
1
2.4k
#Ubie 狂気の認知施策と選考設計
ntaro
14
14k
UbieにおけるサーバサイドKotlin活用事例
ntaro
1
1.2k
KotlinでSpring 完全理解ガイド #jsug
ntaro
6
3.7k
Kotlinでサーバサイドを始めよう!
ntaro
1
1.1k
Androidからサーバーサイドまで!プログラミング言語 Kotlinの魅力 #devboost
ntaro
5
3k
Kotlin Contracts #m3kt
ntaro
4
4.4k
How_to_Test_Server-side_Kotlin.pdf
ntaro
1
580
Other Decks in Programming
See All in Programming
夏だ!祭りだ!祭りとはドメインモデリングでは?
ryugen04
0
310
KotlinConf Extended South Korea 2026 Keynote
l2hyunwoo
0
110
Laravelで学ぶ Webアプリケーションチューニング入門/web_application_tuning_101
hanhan1978
4
1.9k
AI Readyの正体はデータマネジメントだ メダリオン2.0の最前線
freee
PRO
0
280
仕様書を書く前にハーネスを作る - Agent Native開発は「探索を速く、判定を固く」
gotalab555
4
1.7k
属人化した知識を、 AIが辿れる地図にする
pkshadeck
PRO
1
180
Go言語とトイモデルで学ぶTransformerの気持ち / fukuokago23-transformer
monochromegane
0
180
freeeにおけるEvalsの実践例の紹介
freee
PRO
0
120
freee が目指す データ マネジメント戦略 AI-Ready 時代を支える 攻めのガバナンスとは
freee
PRO
0
400
改善しないと、タスクが回らない。 “てんこ盛りポジション” を引き継いだ情シスの、入社3ヶ月の業務改善録
krm963
0
270
Flow は今どうなっているか
mizdra
PRO
0
600
メールのエイリアス機能を履き違えない
isshinfunada
0
240
Featured
See All Featured
Keith and Marios Guide to Fast Websites
keithpitt
413
23k
Stop Working from a Prison Cell
hatefulcrawdad
274
21k
Agile that works and the tools we love
rasmusluckow
331
22k
HU Berlin: Industrial-Strength Natural Language Processing with spaCy and Prodigy
inesmontani
PRO
0
650
Thoughts on Productivity
jonyablonski
76
5.3k
The untapped power of vector embeddings
frankvandijk
2
1.8k
The Hidden Cost of Media on the Web [PixelPalooza 2025]
tammyeverts
2
470
Hiding What from Whom? A Critical Review of the History of Programming languages for Music
tomoyanonymous
3
1.1k
The Art of Programming - Codeland 2020
erikaheidi
57
14k
How to audit for AI Accessibility on your Front & Back End
davetheseo
0
500
The browser strikes back
jonoalderson
0
1.5k
Lightning Talk: Beautiful Slides for Beginners
inesmontani
PRO
2
630
Transcript
Kotlin Null-Safetyػߏʹ͍ͭͯ 2013-11-09 JJUG CCC 2013 fall JVMݴޠύωϧσΟεΧογϣϯ ! ຊKotlinϢʔβάϧʔϓ
ᖒ ଠ
Α͋͘Δᷤ౻ • NullPointerException͕සൃ • NullνΣοΫ • ඞཁѱ
Nullͱ্खʹ͖߹͏ํ๏ • ϝιουγάωνϟͷ • ੩తղੳπʔϧ • ܕΛ࡞ͬͯϥοϓ
ϝιουγάωνϟͷ calc(String s) throws NPE! getNameOrNull()
੩తղੳπʔϧ calc(@NotNull String s)! @NotNull String getName()
ܕΛ࡞ͬͯϥοϓ calc(Optional<String> s)! Optional<String> getName()
͵ΔΆۦஞͰ͖ͳ͍ calc(null);
ͦ͜ͰKotlinͷ! Null-Safety
Null-Safety • NotNull, NullableΛݴޠͰαϙʔτ • Φʔόϔουͳ͠ • Nullableʹͱ͜ͱΜ৻ॏʹͳΔ • Ͱॻ͖͢͞ɺಡΈ͢͞Λҡ࣋
NotNull val name: String
NotNull val name: String = null
NotNull val name: String = null ίϯύΠϧΤϥʔʂ! ࣮ߦՄೳͳόΠτίʔυΛੜ·ͳ͍! ৗʹ҆৺ͯ͠ࢀরͰ͖Δ
NotNull val name: String = null ίϯύΠϧΤϥʔʂ! ࣮ߦՄೳͳόΠτίʔυΛੜ·ͳ͍! ৗʹ҆৺ͯ͠ࢀরͰ͖Δ Null
can not be a value of a non-null type jet.String
Nullable val name: String? = null! name.toUpperCase()
Nullable val name: String? = null! name.toUpperCase() ίϯύΠϧΤϥʔʂ! ෆҙʹΑΔNPEΛഉআ͢Δ
NullνΣοΫٛԽ val name: String? = null! if(name != null)! !
name.toUpperCase() ίϯύΠϧ௨Δ
Safe Call ↓! if(name != null) name.toUpperCase()! else null val
name: String? = null! name?.toUpperCase()
Safe Callศར val got = listOf(“foo”, null) map{! it?.toUpperCase()?.reverse()! }!
! assert(got == listOf(“OOF”, null))
Safe Callͱ૬ੑͷྑ͍ػೳ val name =! (param[“name”] as? String)?.trim()! ! person.setName(name
?: “໊ແ͠”) Safe Cast Elvis operator
NPE͕ൃੜ͢Δ໘ • throw NullPointerException()! • ֎෦Javaίʔυͷݺͼग़͠ • !!ԋࢉࢠͷ༻
͝ਗ਼ௌ͋Γ͕ͱ͏͍͟͝·ͨ͠