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
520
Wantedly のバックエンドの将来に向けた取り組みと課題 - Wantedly Tech Night 2024/5
gedorinku
0
130
Porting mruby/c for the SNES (Super Famicom) - RubyKaigi 2024
gedorinku
0
4.4k
N+1 問題の解決と computed_model
gedorinku
0
88
部内での競プロ用ジャッジシステム
gedorinku
0
1.7k
部内ジャッジを作る話
gedorinku
1
100
プロラボ年度末報告会 HackDay / Hack U 福岡
gedorinku
0
170
Other Decks in Programming
See All in Programming
フロントエンド開発のためのブラウザ組み込みAI入門
masashi
7
3.5k
組込みだけじゃない!TinyGo で始める無料クラウド開発入門
otakakot
2
380
Ktorで簡単AIアプリケーション
tsukakei
0
110
Catch Up: Go Style Guide Update
andpad
0
250
テーブル定義書の構造化抽出して、生成AIでDWH分析を試してみた / devio2025tokyo
kasacchiful
0
300
Domain-centric? Why Hexagonal, Onion, and Clean Architecture Are Answers to the Wrong Question
olivergierke
3
980
Google Opalで使える37のライブラリ
mickey_kubo
3
150
社会人になっても趣味開発を続けたい! / traPavilion
mazrean
1
100
Vueのバリデーション、結局どれを選べばいい? ― 自作バリデーションの限界と、脱却までの道のり ― / Which Vue Validation Library Should We Really Use? The Limits of Self-Made Validation and How I Finally Moved On
neginasu
2
1.6k
The Past, Present, and Future of Enterprise Java
ivargrimstad
0
280
NIKKEI Tech Talk#38
cipepser
0
240
釣り地図SNSにおける有料機能の実装
nokonoko1203
0
200
Featured
See All Featured
StorybookのUI Testing Handbookを読んだ
zakiyama
31
6.2k
Optimising Largest Contentful Paint
csswizardry
37
3.5k
Statistics for Hackers
jakevdp
799
220k
[RailsConf 2023] Rails as a piece of cake
palkan
57
5.9k
Creating an realtime collaboration tool: Agile Flush - .NET Oxford
marcduiker
34
2.3k
個人開発の失敗を避けるイケてる考え方 / tips for indie hackers
panda_program
116
20k
Navigating Team Friction
lara
190
15k
I Don’t Have Time: Getting Over the Fear to Launch Your Podcast
jcasabona
34
2.5k
Reflections from 52 weeks, 52 projects
jeffersonlam
353
21k
Art, The Web, and Tiny UX
lynnandtonic
303
21k
Chrome DevTools: State of the Union 2024 - Debugging React & Beyond
addyosmani
9
930
Become a Pro
speakerdeck
PRO
29
5.6k
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を はじめましょう