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
gedorinku
March 24, 2017
Programming
0
270
Kotlin入門しました
#prolabLT のスライドです.
gedorinku
March 24, 2017
Tweet
Share
More Decks by gedorinku
See All by gedorinku
Active Record Encryption と AWS KMS でエンベロープ暗号化
gedorinku
0
420
Wantedly のバックエンドの将来に向けた取り組みと課題 - Wantedly Tech Night 2024/5
gedorinku
0
110
Porting mruby/c for the SNES (Super Famicom) - RubyKaigi 2024
gedorinku
0
4.3k
N+1 問題の解決と computed_model
gedorinku
0
76
部内での競プロ用ジャッジシステム
gedorinku
0
1.7k
部内ジャッジを作る話
gedorinku
1
98
プロラボ年度末報告会 HackDay / Hack U 福岡
gedorinku
0
160
Other Decks in Programming
See All in Programming
GitHub Copilot and GitHub Codespaces Hands-on
ymd65536
2
140
A full stack side project webapp all in Kotlin (KotlinConf 2025)
dankim
0
100
データの民主化を支える、透明性のあるデータ利活用への挑戦 2025-06-25 Database Engineering Meetup#7
y_ken
0
340
iOS 26にアップデートすると実機でのHot Reloadができない?
umigishiaoi
0
120
PipeCDのプラグイン化で目指すところ
warashi
1
260
PHP 8.4の新機能「プロパティフック」から学ぶオブジェクト指向設計とリスコフの置換原則
kentaroutakeda
2
750
ニーリーにおけるプロダクトエンジニア
nealle
0
780
0626 Findy Product Manager LT Night_高田スライド_speaker deck用
mana_takada
0
150
Is Xcode slowly dying out in 2025?
uetyo
1
260
なんとなくわかった気になるブロックテーマ入門/contents.nagoya 2025 6.28
chiilog
1
270
Quand Symfony, ApiPlatform, OpenAI et LangChain s'allient pour exploiter vos PDF : de la théorie à la production…
ahmedbhs123
0
130
Result型で“失敗”を型にするPHPコードの書き方
kajitack
5
600
Featured
See All Featured
Balancing Empowerment & Direction
lara
1
410
The MySQL Ecosystem @ GitHub 2015
samlambert
251
13k
Java REST API Framework Comparison - PWX 2021
mraible
31
8.7k
個人開発の失敗を避けるイケてる考え方 / tips for indie hackers
panda_program
107
19k
実際に使うSQLの書き方 徹底解説 / pgcon21j-tutorial
soudai
PRO
181
53k
[Rails World 2023 - Day 1 Closing Keynote] - The Magic of Rails
eileencodes
35
2.4k
Cheating the UX When There Is Nothing More to Optimize - PixelPioneers
stephaniewalter
281
13k
Practical Tips for Bootstrapping Information Extraction Pipelines
honnibal
PRO
20
1.3k
BBQ
matthewcrist
89
9.7k
A Tale of Four Properties
chriscoyier
160
23k
JavaScript: Past, Present, and Future - NDC Porto 2020
reverentgeek
48
5.4k
XXLCSS - How to scale CSS and keep your sanity
sugarenia
248
1.3M
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を はじめましょう