Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
Kotlin入門しました
Search
Sponsored
·
SiteGround - Reliable hosting with speed, security, and support you can count on.
→
gedorinku
March 24, 2017
Programming
300
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Kotlin入門しました
#prolabLT のスライドです.
gedorinku
March 24, 2017
Transcript
10 slides
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を はじめましょう
More Decks by gedorinku
See All by gedorinku
Active Record Encryption と AWS KMS でエンベロープ暗号化
gedorinku
0
840
Wantedly のバックエンドの将来に向けた取り組みと課題 - Wantedly Tech Night 2024/5
gedorinku
0
180
Porting mruby/c for the SNES (Super Famicom) - RubyKaigi 2024
gedorinku
0
5.1k
N+1 問題の解決と computed_model
gedorinku
0
140
部内での競プロ用ジャッジシステム
gedorinku
0
1.8k
部内ジャッジを作る話
gedorinku
1
130
プロラボ年度末報告会 HackDay / Hack U 福岡
gedorinku
0
190
Other Decks in Programming
See All in Programming
はじめてのPLATEAU
nokonoko1203
1
660
SODA - FACT BOOK(JP)
sodainc
1
40k
AIコーディング時代のKotest ユニットテストから APIレベルの仕様固定化テストへ
ooga04
0
330
Growing PicoRuby's Ecosystem on ESP32
yuuu
2
150
[DroidKnights 2026] Workflow AX 적용기 — 자동 정책 정리부터 E2E까지
dayeon
0
120
Kotlin JVM用に作られたライブラリのKMPを前提とした再設計
jsoizo
0
230
動画プレイヤーはなぜカクつくのか 〜Flutterのレンダリングとネイティブの境界を解剖する〜
naruogram
0
340
小さなアプリを作って公開するまで
onozaty
0
220
まずはコードより業務と向き合う:テーブル解体のためにPdMを呼んだ話
sakawe_ee
0
270
手の動かし方がわからなかった私が個人開発者になるまで
usagi0920_pochi
0
330
AIが実装を担う時代の「技術設計」と「チームマネジメント」
kamina_zzz
2
410
止まらない比較を止める — 余帰納法で無限ストリームを比べる
tarao
0
210
Featured
See All Featured
CoffeeScript is Beautiful & I Never Want to Write Plain JavaScript Again
sstephenson
162
16k
Jess Joyce - The Pitfalls of Following Frameworks
techseoconnect
PRO
1
480
Rebuilding a faster, lazier Slack
samanthasiow
85
9.8k
How to audit for AI Accessibility on your Front & Back End
davetheseo
0
640
Public Speaking Without Barfing On Your Shoes - THAT 2023
reverentgeek
1
670
No one is an island. Learnings from fostering a developers community.
thoeni
21
3.9k
Raft: Consensus for Rubyists
vanstee
143
7.9k
jQuery: Nuts, Bolts and Bling
dougneiner
66
8.7k
Noah Learner - AI + Me: how we built a GSC Bulk Export data pipeline
techseoconnect
PRO
0
500
Art, The Web, and Tiny UX
lynnandtonic
304
22k
Discover your Explorer Soul
emna__ayadi
2
1.3k
30 Presentation Tips
portentint
PRO
1
480