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
290
UnixTime is Simple
mattak
0
240
おっさんが停滞しないために
mattak
32
18k
tech invest
mattak
1
350
Nodux - node base redux framework
mattak
0
1.5k
what_is_technical_investment
mattak
0
150
unitypackage distribution
mattak
0
870
Unity energy usage
mattak
0
960
Unidux 0.3.1
mattak
1
430
Other Decks in Technology
See All in Technology
What happened to RubyGems and what can we learn?
mikemcquaid
0
280
マーケットプレイス版Oracle WebCenter Content For OCI
oracle4engineer
PRO
5
1.6k
AI駆動PjMの理想像 と現在地 -実践例を添えて-
masahiro_okamura
1
110
Kiro IDEのドキュメントを全部読んだので地味だけどちょっと嬉しい機能を紹介する
khmoryz
0
180
M&A 後の統合をどう進めるか ─ ナレッジワーク × Poetics が実践した組織とシステムの融合
kworkdev
PRO
1
430
AIエージェントを開発しよう!-AgentCore活用の勘所-
yukiogawa
0
150
Digitization部 紹介資料
sansan33
PRO
1
6.8k
会社紹介資料 / Sansan Company Profile
sansan33
PRO
15
400k
All About Sansan – for New Global Engineers
sansan33
PRO
1
1.3k
Sansan Engineering Unit 紹介資料
sansan33
PRO
1
3.8k
20260208_第66回 コンピュータビジョン勉強会
keiichiito1978
0
110
SREじゃなかった僕らがenablingを通じて「SRE実践者」になるまでのリアル / SRE Kaigi 2026
aeonpeople
6
2.2k
Featured
See All Featured
Product Roadmaps are Hard
iamctodd
PRO
55
12k
What the history of the web can teach us about the future of AI
inesmontani
PRO
1
430
Sam Torres - BigQuery for SEOs
techseoconnect
PRO
0
180
Mobile First: as difficult as doing things right
swwweet
225
10k
Navigating Algorithm Shifts & AI Overviews - #SMXNext
aleyda
0
1.1k
Imperfection Machines: The Place of Print at Facebook
scottboms
269
14k
Why You Should Never Use an ORM
jnunemaker
PRO
61
9.7k
Primal Persuasion: How to Engage the Brain for Learning That Lasts
tmiket
0
250
Lessons Learnt from Crawling 1000+ Websites
charlesmeaden
PRO
1
1.1k
Digital Projects Gone Horribly Wrong (And the UX Pros Who Still Save the Day) - Dean Schuster
uxyall
0
330
Producing Creativity
orderedlist
PRO
348
40k
The #1 spot is gone: here's how to win anyway
tamaranovitovic
2
930
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✨