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
830
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
SFCで実現する病院・医療システムの動的組み立て式UI
koukimiura
1
180
はじめてのPLATEAU
nokonoko1203
1
660
小さなアプリを作って公開するまで
onozaty
0
200
Debian JP Projectのサーバー構成
uwabami
1
140
作れるエンジニアから、価値を届けるエンジニアへ
ryunakayama
1
310
プロジェクトコードをキレイキレイしよう!暗黙的な参照を読み解く静的解析
ostk0069
0
220
将来の標準フォーマッター?ktfmtを深堀る
t45k
0
220
学びを記事・スライド・Xへ高速展開する― AI-assisted Learning Loopで回すコンテンツ生成術
ochtum
0
210
baseline으로 마이그레이션, 리팩토링 안전하게 맡기기
fornewid
1
1k
SODA - FACT BOOK(JP)
sodainc
1
40k
Kotlin JVM用に作られたライブラリのKMPを前提とした再設計
jsoizo
0
210
AI時代のIaC入門 〜なぜインフラをコードで管理したいのか?〜 / Introduction to IaC in the AI Era
akihisaikeda
6
1.6k
Featured
See All Featured
Art, The Web, and Tiny UX
lynnandtonic
304
22k
My Coaching Mixtape
mlcsv
0
390
Digital Projects Gone Horribly Wrong (And the UX Pros Who Still Save the Day) - Dean Schuster
uxyall
2
4k
Reality Check: Gamification 10 Years Later
codingconduct
0
2.4k
RailsConf 2023
tenderlove
30
1.6k
Code Review Best Practice
trishagee
74
20k
Technical Leadership for Architectural Decision Making
baasie
4
650
Designing Powerful Visuals for Engaging Learning
tmiket
1
660
KATA
mclloyd
PRO
35
16k
A Soul's Torment
seathinner
9
3.9k
Let's Do A Bunch of Simple Stuff to Make Websites Faster
chriscoyier
508
140k
Claude Code どこまでも/ Claude Code Everywhere
nwiizo
68
61k