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入門しました
Search
Sponsored
·
Ship Features Fearlessly
Turn features on and off without deploys. Used by thousands of Ruby developers.
→
gedorinku
March 24, 2017
Programming
280
0
Share
Kotlin入門しました
#prolabLT のスライドです.
gedorinku
March 24, 2017
More Decks by gedorinku
See All by gedorinku
Active Record Encryption と AWS KMS でエンベロープ暗号化
gedorinku
0
650
Wantedly のバックエンドの将来に向けた取り組みと課題 - Wantedly Tech Night 2024/5
gedorinku
0
150
Porting mruby/c for the SNES (Super Famicom) - RubyKaigi 2024
gedorinku
0
4.8k
N+1 問題の解決と computed_model
gedorinku
0
110
部内での競プロ用ジャッジシステム
gedorinku
0
1.8k
部内ジャッジを作る話
gedorinku
1
120
プロラボ年度末報告会 HackDay / Hack U 福岡
gedorinku
0
170
Other Decks in Programming
See All in Programming
一度始めたらやめられない開発効率向上術 / Findy あなたのdotfilesを教えて!
k0kubun
4
3k
Server-Side Kotlin LT大会 vol.18 [Kotlin-lspの最新情報と Neovimのlsp設定例]
yasunori0418
1
160
PicoRuby for IoT: Connecting to the Cloud with MQTT
yuuu
2
620
ハンズオンで学ぶクラウドネイティブ
tatsukiminami
0
130
Vibe NLP for Applied NLP
inesmontani
PRO
0
440
アクセシビリティ試験の"その後"を仕組み化する
yuuumiravy
0
150
年間50登壇、単著出版、雑誌寄稿、Podcast出演、YouTube、CM、カンファレンス主催……全部やってみたので面白さ等を比較してみよう / I’ve tried them all, so let’s compare how interesting they are.
nrslib
4
790
How We Benchmarked Quarkus: Patterns and anti-patterns
hollycummins
1
150
Coding at the Speed of Thought: The New Era of Symfony Docker
dunglas
0
5k
AIベース静的検査器の偽陽性率を抑える工夫3選
orgachem
PRO
3
330
의존성 주입과 모듈화
fornewid
0
150
Back to the roots of date
jinroq
0
250
Featured
See All Featured
The Hidden Cost of Media on the Web [PixelPalooza 2025]
tammyeverts
2
270
jQuery: Nuts, Bolts and Bling
dougneiner
66
8.4k
SERP Conf. Vienna - Web Accessibility: Optimizing for Inclusivity and SEO
sarafernandez
2
1.4k
Breaking role norms: Why Content Design is so much more than writing copy - Taylor Woolridge
uxyall
0
260
The Illustrated Children's Guide to Kubernetes
chrisshort
51
52k
Joys of Absence: A Defence of Solitary Play
codingconduct
1
350
Done Done
chrislema
186
16k
I Don’t Have Time: Getting Over the Fear to Launch Your Podcast
jcasabona
34
2.7k
技術選定の審美眼(2025年版) / Understanding the Spiral of Technologies 2025 edition
twada
PRO
118
110k
What’s in a name? Adding method to the madness
productmarketing
PRO
24
4k
Faster Mobile Websites
deanohume
310
31k
Digital Ethics as a Driver of Design Innovation
axbom
PRO
1
270
Transcript
Kotlin入門しました @gedorinku
Kotlin #とは • JetBrainsが作った言語 • JVMで動く • Androidでも使える • 安全で簡潔な記述ができる
• null安全 • SAM変換 • 拡張関数 • delegation とか • 名前がかわいい
null安全ー?なにそれー? JavaやKotlinはnullを参照すると ぬるぽ(NullPointerException)で止まる 回避するにはnullを参照しようとしてないか 頑張ってチェックする・・・?
null許容型・非null型 fun main(args: Array<String>) { var hoge: Array<Int> = null
var piyo: Array<Int>? = null //something to do val evenCount = piyo?.count { it % 2 == 0 } ?: 0 } ←コンパイルエラー ←OK null許容型はnullチェックして参照しないとコンパイルエラー
Javaとの連携とSAM変換 val runnable = Runnable { println("hogehoge") } KotlinからJavaのクラスは普通に使える 抽象メソッド1つを実装した匿名クラスは簡潔に書ける
(Java8っぽい)
拡張関数・拡張プロパティ 既存のクラスに後からメソッドを追加する機能 fun String.chan(): String = this + "-chan" println("Serval".chan())
//-> Serval-chan
キモイことができます operator fun Int.invoke(): Int = this * 2 fun
Int.println() = println(this) 1()()().println() //-> 8
既存のクラスに後からメソッドを追加する機能 //-> [0, 8, 16] fun Array<Int>.applyMany( times: Int, f:
Array<Int>.() -> Unit ): Array<Int> { for (i in 1..times) { f() } return this } fun main(args: Array<String>) { println(arrayOf(0, 1, 2).applyMany(3) { forEachIndexed { index, i -> this[index] = i * 2 } }.toList()) }
Kotlin Koans IDEを使って チュートリアルをやると 幸せになれる 全部理解できたらプロ.
Kotlin Koans Kotlin Koansを進めると, いい感じのgif付きで ツイートできる Kotlin KoansでKotlinを はじめましょう