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
290
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Kotlin入門しました
#prolabLT のスライドです.
gedorinku
March 24, 2017
More Decks by gedorinku
See All by gedorinku
Active Record Encryption と AWS KMS でエンベロープ暗号化
gedorinku
0
690
Wantedly のバックエンドの将来に向けた取り組みと課題 - Wantedly Tech Night 2024/5
gedorinku
0
160
Porting mruby/c for the SNES (Super Famicom) - RubyKaigi 2024
gedorinku
0
4.8k
N+1 問題の解決と computed_model
gedorinku
0
120
部内での競プロ用ジャッジシステム
gedorinku
0
1.8k
部内ジャッジを作る話
gedorinku
1
120
プロラボ年度末報告会 HackDay / Hack U 福岡
gedorinku
0
170
Other Decks in Programming
See All in Programming
Lemonade + Foundry Toolkit でお手軽アプリ開発
seosoft
1
320
コンテキストの使い捨てをやめる — ビジネスルール駆動開発と miko —
ioki
0
190
Vite+ Unified Toolchain for the Web
naokihaba
0
280
決定論的オーケストレーションの設計と実装 / Design and Implementation of Deterministic Orchestration
nrslib
3
1.3k
JJUG CCC 2026 Spring: JSpecify で実現する Kotlin フレンドリーな Java API 設計
ternbusty
1
160
技術記事、 専門家としてのプログラマ、 言語化
mizchi
5
3.1k
Contextとはなにか
chiroruxx
1
290
作って学ぶ、 JSX (TSX) ランタイムの基本
syumai
7
1.6k
jQueryをバージョンアップする前に使いたいjQuery Migrate
matsuo_atsushi
0
200
ECSアプリログをFireLensでコスト削減しようとしたけど諦めた話 in Fargate×Node.js
akihisaikeda
2
4k
AI時代の仕事技芸論 — ソフトウェア開発で「遊ぶように働く」職人的熟達のすすめ
kuranuki
2
660
RTSPクライアントを自作してみた話
simotin13
0
580
Featured
See All Featured
Stewardship and Sustainability of Urban and Community Forests
pwiseman
0
220
Effective software design: The role of men in debugging patriarchy in IT @ Voxxed Days AMS
baasie
0
400
Docker and Python
trallard
47
3.9k
"I'm Feeling Lucky" - Building Great Search Experiences for Today's Users (#IAC19)
danielanewman
231
23k
What the history of the web can teach us about the future of AI
inesmontani
PRO
1
610
Design in an AI World
tapps
1
240
SEO for Brand Visibility & Recognition
aleyda
0
4.6k
Self-Hosted WebAssembly Runtime for Runtime-Neutral Checkpoint/Restore in Edge–Cloud Continuum
chikuwait
0
580
Kristin Tynski - Automating Marketing Tasks With AI
techseoconnect
PRO
0
270
HDC tutorial
michielstock
2
700
[Rails World 2023 - Day 1 Closing Keynote] - The Magic of Rails
eileencodes
38
2.9k
<Decoding/> the Language of Devs - We Love SEO 2024
nikkihalliwell
1
240
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を はじめましょう