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
mattak
October 08, 2015
Technology
1
1.1k
かゆいところに手が届くKotlin
Kotlin's 8 tips.
mattak
October 08, 2015
Tweet
Share
More Decks by mattak
See All by mattak
最近やった作業環境改善施策10個
mattak
0
270
UnixTime is Simple
mattak
0
200
おっさんが停滞しないために
mattak
32
18k
tech invest
mattak
1
320
Nodux - node base redux framework
mattak
0
1.5k
what_is_technical_investment
mattak
0
130
unitypackage distribution
mattak
0
820
Unity energy usage
mattak
0
920
Unidux 0.3.1
mattak
1
410
Other Decks in Technology
See All in Technology
microCMS 最新リリース情報(microCMS Meetup 2025)
microcms
0
100
フルカイテン株式会社 エンジニア向け採用資料
fullkaiten
0
8.6k
MySQL HeatWave:サービス概要のご紹介
oracle4engineer
PRO
4
1.7k
7月のガバクラ利用料が高かったので調べてみた
techniczna
3
390
事業価値と Engineering
recruitengineers
PRO
1
210
実践アプリケーション設計 ①データモデルとドメインモデル
recruitengineers
PRO
2
240
LLM時代の検索とコンテキストエンジニアリング
shibuiwilliam
2
1.1k
トヨタ生産方式(TPS)入門
recruitengineers
PRO
2
220
小さなチーム 大きな仕事 - 個人開発でAIをフル活用する
himaratsu
0
120
第4回 関東Kaggler会 [Training LLMs with Limited VRAM]
tascj
12
1.7k
Goss: New Production-Ready Go Binding for Faiss #coefl_go_jp
bengo4com
0
1.1k
【5分でわかる】セーフィー エンジニア向け会社紹介
safie_recruit
0
30k
Featured
See All Featured
実際に使うSQLの書き方 徹底解説 / pgcon21j-tutorial
soudai
PRO
183
54k
How to Ace a Technical Interview
jacobian
279
23k
For a Future-Friendly Web
brad_frost
179
9.9k
Designing Experiences People Love
moore
142
24k
ピンチをチャンスに:未来をつくるプロダクトロードマップ #pmconf2020
aki_iinuma
126
53k
Let's Do A Bunch of Simple Stuff to Make Websites Faster
chriscoyier
507
140k
Done Done
chrislema
185
16k
jQuery: Nuts, Bolts and Bling
dougneiner
64
7.9k
The Invisible Side of Design
smashingmag
301
51k
Why Our Code Smells
bkeepers
PRO
338
57k
The Power of CSS Pseudo Elements
geoffreycrofte
77
5.9k
Build The Right Thing And Hit Your Dates
maggiecrowley
37
2.8k
Transcript
͔Ώ͍ͱ͜Ζʹ ख͕ಧ͘ ,PUMJO/JHIU !NBUUBL
,PUMJOͷศརͳॻ͖ํͭհ͢ΔΑ
MB[Z ✨ΪϦΪϦ·Ͱ࣮ߦ͠ͳ͍✨
class Person( val firstName: String, val lastName: String ) {
val fullName by lazy { “${firstName}, ${lastName}” } } // ͜ͷ࣌Ͱ fullNameͭ͘ΒΕͳ͍ val person = Person(“John”, “Due”) // ΞΫηεͯ͠ॳΊͯ࡞͞ΕΔ println(person.fullName)
MFU OJMDPBMFTDJOHPQFSBUPS ✨JGMFUͯ͠ฦΓ͕΄͍͠✨
// ී௨ͷॻ͖ํ var name: String? = “Kana” var message: String
= if (name!=null) “Hello, ${name}!” else “Hello.” // let+null coalescing op var name: String? = “Kana” var message: String = name?.let { “Hello, ${it}!” } ?: “Hello.”
DMBTTKBWB ✨KBWBͷΫϥεΦϒδΣΫτ͕΄͍͠✨
// ී௨ͷॻ͖ํ javaClass<Sample>() // M13Ҏ߱ͷॻ͖ํ Sample::class.java // ͍υίϩɺ(TPOύʔε͢Δͱ͖ͳͲ val gson
= Gson() val person = gson.fromJson(“{\”name\”: \”Ocelot\”}”, Person::class.java)
HFUUFSTFUUFS ✨HFUUFSTFUUFS͕͔ΜͨΜʹ͔͚ΔΑ✨
// Computed properties class Duration(val interval: Long) { var seconds:
Double get() = interval.toDouble() / 1000 set(value) { this.interval = value * 1000 } } // javaͷsetter/getter͕KotlinͩͱpropertyʹͳΔΑ person.name = “John” // person.setName(String name) person.name // person.getName()
0CKFDU ✨4JOHMFUPO͕΄͍͠ʂ✨
// java class Singleton { private static Singleton instance =
null; public static Singleton getInstance() { if (instance == null) { instance = new Singleton(); } return instance; } } // kotlin object Singleton() // Objectlazy. ॳճΞΫηεͰOFX͞ΕΔ Singleton
// java class NotSingleton { public static void callClassMethod() {}
} NotSingleton.callClassMethod(); // kotlin class NotSingleton { companion object { fun callClassMethod() {} } } NotSingleton.callClassMethod()
UIJT! ✨ͲͷUIJT͔໌ࣔͯ͠ΞΫηε͍ͨ͠✨
class A { inner class B { fun doit() {
val a = this@A // instance of class A val b = this@B // instance of class B } } }
6OJU ✨+BWBͷ7PJEʹରԠ͢Δͭ✨
public open class UpdateModel { // ΠϕϯτΛૹ৴͍͚ͨ͠ͲɺແҙຯͳΛૹΓ͍ͨ࣌ͱ͔ val updateEvent by
lazy { BehaviorSubject.create<Unit>() } fun update() { // Unit Object. ৽͍͠instanceΛͭ͘Βͳ͍ updateEvent.onNext(Unit) } }
&YUFOTJPO ✨طଘͷΫϥεʹϝιουΛ͚͍ͨ͠✨
// طଘͷΫϥεΛ֦ுग़དྷΔ fun <T> Observable<T?>.notNulls(): Observable<T> { return this.filter {
it != null }. map { it!! } } // ΑΓγϯϓϧʹʂ val observable = Observable.just<Int?>(1, null, 2, null) val normal = observable.filter { it != null }. map { it !! } val pretty = observable.notNulls()
͍͡ΐ͏Ͱ͢ ✨&OKPZLPUMJO✨