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/JSと格闘しながらKotlinのイケてる文法を学ぶ
Search
Sponsored
·
Ship Features Fearlessly
Turn features on and off without deploys. Used by thousands of Ruby developers.
→
subroh_0508
March 19, 2019
Technology
800
0
Share
Kotlin/JSと格闘しながらKotlinのイケてる文法を学ぶ
【とらのあな主催】オタクがKotlinを追うライトニングトークイベントのLT発表資料です
subroh_0508
March 19, 2019
More Decks by subroh_0508
See All by subroh_0508
"S/N-GUL4R1TY"に向けて人類は何をすべきなのか
subroh0508
0
20
画面の向こうから「気づき」を得る 画面の向こうを「物差し」として捉える
subroh0508
1
210
蓮ノ空女学院スクールアイドルクラブはなぜ強いのか
subroh0508
0
59
2026年、書籍をちゃんと読むぞ👊 〜約3万円分の書籍を積読にしないためにやること〜
subroh0508
5
850
「発信の依頼」が採用広報活動の立ち上げに効くかもしれない
subroh0508
1
780
技術以外の世界に『越境』しエンジニアとして進化を遂げる 〜Kotlinへの愛とDevHRとしての挑戦を添えて〜
subroh0508
1
1.4k
10分de名コミュ “最高の自分”を演じ憧れの同業者と渡り合う
subroh0508
1
640
カンファレンス協賛を社員の成長機会に変える
subroh0508
0
170
ネガティブをねじ伏せ、n=1のキャリアに変える技術
subroh0508
1
1.2k
Other Decks in Technology
See All in Technology
はじめての MagicPod生成AI機能 機能紹介から活用方法まで
magicpod
0
120
AWS Transform CustomでIaCコードを自由自在に変換しよう
duelist2020jp
0
200
CloudTrail を見つめ直してみる
kazzpapa3
1
120
AWS Agent Registry の基礎・概要を理解する/aws-agent-registry-intro
ren8k
3
410
PicoRuby as a Multi-VM Operating System
kishima
1
230
Percolatorを廃止し、マルチ検索サービスへ刷新した話 / Search Engineering Tech Talk 2026 Spring
visional_engineering_and_design
0
180
20260428_Product Management Summit_Loglass_JoeHirose
loglassjoe
4
4.3k
Modernizing Your HCL Connections Experience: Visual Report to chain, Profile Enhancements, and AI Integration
wannesrams
0
130
GitHub Copilot Dev Days
tomokusaba
0
100
Arcana: Production-Ready RAG in Elixir @ ElixirConf EU 2026
georgeguimaraes
0
120
AI活用時代の事業判断高度化を導くエンジニアリング基盤 / 20260424 Atsushi Funahashi
shift_evolve
PRO
2
100
社内エンジニア勉強会の醍醐味と苦しみ/tamadev
nishiuma
0
260
Featured
See All Featured
Let's Do A Bunch of Simple Stuff to Make Websites Faster
chriscoyier
508
140k
Avoiding the “Bad Training, Faster” Trap in the Age of AI
tmiket
0
130
Why You Should Never Use an ORM
jnunemaker
PRO
61
9.8k
The Organizational Zoo: Understanding Human Behavior Agility Through Metaphoric Constructive Conversations (based on the works of Arthur Shelley, Ph.D)
kimpetersen
PRO
0
320
Agile Actions for Facilitating Distributed Teams - ADO2019
mkilby
0
180
StorybookのUI Testing Handbookを読んだ
zakiyama
31
6.7k
Collaborative Software Design: How to facilitate domain modelling decisions
baasie
1
200
Bridging the Design Gap: How Collaborative Modelling removes blockers to flow between stakeholders and teams @FastFlow conf
baasie
0
530
Fantastic passwords and where to find them - at NoRuKo
philnash
52
3.7k
Leveraging LLMs for student feedback in introductory data science courses - posit::conf(2025)
minecr
1
240
Marketing Yourself as an Engineer | Alaka | Gurzu
gurzu
0
180
Ruling the World: When Life Gets Gamed
codingconduct
0
210
Transcript
,PUMJO+4ͱ֨ಆ͠ͳ͕Β ,PUMJOͷΠέͯΔจ๏ΛֶͿ ʹ͜͠Γ͞ͿΖʙ!TVCSPI@
ࣗݾհ w ʹ͜͠Γ͞ͿΖʙ ຊ໊ࡔ্৴ w גࣜձࣾ#FBS5BJM w "OESPJEΤϯδχΞ ,PUMJO+BWB
ˑ w 8FCΤϯδχΞ 3BJMT3FBDU w ,PUMJOྺ
࣍ ,PUMJO+4ͷ֓ཁ ,PUMJOͷΠέͯΔจ๏հ w ϥϜμࣜ w ֦ுؔ w
ԋࢉࢠΦʔόʔϩʔυ ,PUMJO+4ͱͷ֨ಆͷه
,PUMJO+4ͷ֓ཁ w ϑϩϯτΤϯυͷίʔυ,PUMJOͰॻ͍ͯ͠·͓͏ʂ w ,PUMJOˠ+4ʹมɺ(SBEMFϓϥάΠϯΛ+FU#SBJOT͕ఏڙ w LPUMJOKTɺLPUMJOGSPOUFOEQMVHJO w (SBEMFʹίϯύΠϧ8FCQBDLͷઃఆΛهड़ w
࣮ߦˠ+4มޙͷϑΝΠϧ͕ग़ྗ͞ΕΔ
,PUMJOͰ+4͕ॻ͚Δʜ w ܕ҆શʂॻ͖׳Εͨ,PUMJOͰϑϩϯτΤϯυॻָ͚͍ͯ͠ʂ w ਓྨʹ·ͩૣ͗͢Δ ࣮ࡍʹ֨ಆͨ࣌͠ͷͭΒΈޙ΄Ͳʜ w ίʔυϦʔσΟϯάˠ,PUMJOͷݴޠ༷Λϑϧʹ׆༻ w
ಛʹΑͦ͞͏ͳϞϊΛ͍͔ͭ͘հ w %4- υϝΠϯݻ༗ݴޠ ͷ࣮ʹʹཱͭ
,PUMJOͷΠέͯΔจ๏հ w ϥϜμࣜؔΛએݴͤͣɺͦͷͰมͷΑ͏ʹ͢ // 2つのInt型変数の和を返す val sum = { x:
Int, y: Int -> x + y } print(sum(3, 4)) // => 7 // 別の関数の引数として渡すことも可 fun addAndTimes(sum: (Int, Int) -> Int, n: Int): Int { return sum(n, n) * n } print(addAndTimes(sum, 5)) // => 50
,PUMJOͷΠέͯΔจ๏հ w ֦ுؔطଘͷΫϥεʹ֎͔Β৽ؔ͘͠ΛՃ͢Δ w 4UBUJDͳϝιουΛՃ+BWB͔ΒΫϥεϝιουͱͯ͠ղऍ // Int型のリストに平均値を返す関数を追加 fun List<Int>.average(): Double
{ return this.sum().toDouble() / this.size.toDouble() } print(listOf(1, 2, 3, 4).average()) // => 2.5
,PUMJOͷΠέͯΔจ๏հ w ԋࢉࢠΦʔόʔϩʔυԋࢉࢠͷॲཧΛॻ͖͑Δ w ීஈ͔͍ͮ͋·Γ͠ͳ͍ɺ%4-Λ࡞Δ࣌ʹͱͯศར data class Person(val name: String)
data class People(val names: List<String>) // Person同士を足してPeopleに変換して返す operator fun Person.plus(other: Person): People = People(listOf(this.name, other.name)) Person("音無小鳥") + Person("青羽美咲") // => People(["音無小鳥", "青羽美咲"])
,PUMJO+4Ͱʜ w 3FBDUͷSFOEFSϝιουΛ,PUMJO+4Ͱॻ͘ͱʜ class App : RComponent<RProps, RState>() { override
fun RBuilder.render() { div("title") { +"Welcome to React with Kotlin" } } } class App extends React.Component { render() { return ( <div className='title'> Welcome to React with Kotlin </div> ) } } ,PUMJO+4 3FBDU
,PUMJO+4Ͱʜ w 3FBDUͷSFOEFSϝιουΛ,PUMJO+4Ͱॻ͘ͱʜ class App : RComponent<RProps, RState>() { override
fun RBuilder.render() { div("title") { +"Welcome to React with Kotlin" } } }
,PUMJO+4Ͱʜ w 3FBDUͷSFOEFSϝιουΛ,PUMJO+4Ͱॻ͘ͱʜ class App : RComponent<RProps, RState>() { override
fun RBuilder.render() { div("title") { +"Welcome to React with Kotlin" } } } SFOEFSϝιου͕ ʮ3#VJMEFSΫϥεͷ֦ுؔʯ ͱͯ͠ఆٛ
,PUMJO+4Ͱʜ w 3FBDUͷSFOEFSϝιουΛ,PUMJO+4Ͱॻ͘ͱʜ class App : RComponent<RProps, RState>() { override
fun RBuilder.render() { div("title") { +"Welcome to React with Kotlin" } } } EJW ϝιου ˠEJWλάΛߏங͢Δ
fun RBuilder.div( classes: String? = null, block: RDOMBuilder<DIV>.() -> Unit
): ReactElement = … ,PUMJO+4Ͱʜ w 3FBDUͷSFOEFSϝιουΛ,PUMJO+4Ͱॻ͘ͱʜ class App : RComponent<RProps, RState>() { override fun RBuilder.render() { div("title") { +"Welcome to React with Kotlin" } } } EJW ϝιου ˠ3#VJMEFSΫϥεͷ֦ுؔ
fun RBuilder.div( classes: String? = null, block: RDOMBuilder<DIV>.() -> Unit
): ReactElement = … ,PUMJO+4Ͱʜ w 3FBDUͷSFOEFSϝιουΛ,PUMJO+4Ͱॻ͘ͱʜ class App : RComponent<RProps, RState>() { override fun RBuilder.render() { div("title") { +"Welcome to React with Kotlin" } } } SFOEFS είʔϓͷUIJT 3#VJMEFSΫϥε ˠUIJTEJW\ʜ^EJW\ʜ^ )UNMͬΆ͍ݟͨͰॻ͚Δ ˠ֦ுؔͰείʔϓ੍ޚ
fun RBuilder.div( classes: String? = null, block: RDOMBuilder<DIV>.() -> Unit
): ReactElement = … ,PUMJO+4Ͱʜ w 3FBDUͷSFOEFSϝιουΛ,PUMJO+4Ͱॻ͘ͱʜ class App : RComponent<RProps, RState>() { override fun RBuilder.render() { div("title") { +"Welcome to React with Kotlin" } } } ϥϜμࣜ ҾΛऔΒͳ͍ɺԿฦ͞ͳ͍ είʔϓͷUIJT͕ 3%0.#VJMEFSʹͳΔ ˞3%0.#VJMEFSFYUFOET3#VJMEFS
,PUMJO+4Ͱʜ w 3FBDUͷSFOEFSϝιουΛ,PUMJO+4Ͱॻ͘ͱʜ class App : RComponent<RProps, RState>() { override
fun RBuilder.render() { div("title") { +"Welcome to React with Kotlin" } } } ԋࢉࢠΦʔόʔϩʔυ ˠʮEJWλάͰจࣈྻΛڬΉʯ ˠPQFSBUPSGVO4USJOHVOBSZ1MVT Ͳ͜Ͱ࣮͞ΕͯΔͷʁ
w 3FBDUͷSFOEFSϝιουΛ,PUMJO+4Ͱॻ͘ͱʜ open class RBuilder { operator fun String.unaryPlus() {
childList.add(this) } ... } ,PUMJO+4Ͱʜ class App : RComponent<RProps, RState>() { override fun RBuilder.render() { div("title") { +"Welcome to React with Kotlin" } } } 3#VJMEFSͷதʹ࣮ʂ SFOEFSEJWͷείʔϓͳΒ zIPHFzˠDIJME-JTUBEE lIPHFz ˠϥϜμࣜʹΑΔ είʔϓ੍ޚͷ͓͔͛ ˠԋࢉࢠΦʔόʔϩʔυࠇຐज़ ͑ΔՕॴΛݶఆɺ෭࡞༻⾪
·ͱΊ w ϥϜμࣜɺ֦ுؔɺԋࢉࢠΦʔόʔϩʔυͷϞμϯͳจ๏ w ݴޠͱͯ͠ͷදݱྗ͕ߴ͍ w είʔϓ੍ޚΛҙࣝ͢Δͱɺීஈݣ͍ͷ࣌ʹ׆͔ͤΔ w "OESPJEαʔόʔαΠυ͔ΒˠΓͳ͘ͳ͖ͬͯͨΒ,PUMJO+4
,PUMJO+4ͱͷ֨ಆͷه w ͖͔͚ͬ w #ʮαʔόʔαΠυ,PUMJO৮Γ͍ͨʔʯˠௐΔ w #ʮ,PUMJO+4ʜʁɹϑϩϯτ,PUMJOͰॻ͚Δͷ͔ʯˠॻ͍ͯΈΔ
,PUMJO+4ͱͷ֨ಆͷه w ׂͱΠέͨ DSFBUFSFBDULPUMJOBQQ (JUIVC w ,PUMJO+4 3FBDUͷڥΛ ༻ҙͯ͘͠ΕΔOQNϞδϡʔϧ
w $44͔Β)UNM·Ͱશͯ,PUMJOԽͰ͖ͨ
,PUMJOͷ8FCαΠτ ࡞Δ͔͠Ͷ͑ʂ ,PUMJOͷ8FCαΠτ࣮࣭ͬͯখௗ͞ΜͩΑͶʜ ͦΕ࡞ͬͨΒখௗ͞ΜͷੜΈͷͱݴͬͯաݴͰͳ͍ͷͰʜ
,PUMJO+4ͱͷ֨ಆͷه w ࠈ͔͜͜Β w +4ͷϥΠϒϥϦʮ.BUFSJBM6*ʯΛͬͯ࡞Δͧ w ಥવͷొɺʮEZOBNJDʯܕ @JsModule("@material-ui/core/Button") private external
val buttonModule: dynamic @Suppress("UnsafeCastFromDynamic") private val buttonComponent: RComponent<RProps, RState> = buttonModule.default ίϨ
,PUMJO+4ͱͷ֨ಆͷه w EZNBOJDܕ,PUMJOͱ+4ͷϒϦοδʹඞਢͳຐ๏ͷܕ w \GPPbGPP` CBS\IPHF^^ͱ͍͏ΦϒδΣΫτͷ߹ʜ val jsObject: dynamic =
js("{ foo: 'foo', bar: { hoge: '111' } }") print(jsObject["foo"]) // => 'foo' print(jsObject["bar"]["hoge"]) // => 111 jsObject["aaa"]["bbb"] = "add from kotlin" print(jsObject["aaa"]["bbb"]) // => add from kotlin ͋ɺ͋Γͷ··ࠓىͬͨ͜͜ͱΛͥ͢ʜ ʮΦϨ,PUMJOΛॻ͍͍ͯΔͱࢥͬͨΒ +BWBTDSJQUΛॻ͍͍ͯͨʯ ͳɺԿΛݴͬͯΔ͔Θ͔ΒͶʔͱ SZ
,PUMJO+4ͱͷ֨ಆͷه w +4ϥΠϒϥϦΛ͏ʹɺEZOBNJDΛΑ͠ͳʹม͢ΔΫϥε͕ඞਢʂ w .BUFSJBM6*ɺίϯϙʔωϯτҎ্ɹશͯϥούʔ͕ඞཁ w ϥούʔϥΠϒϥϦӶҙ࡞தʂ8FMDPNF$POUSJCVUFT ,PUMJO.BUFSJBM6*TVCSPILPUMJONBUFSJBMVJ
None
ࠓͳΒԿͯ͠Εͳ͘ઌۦऀʂ ,PUMJO+4ָ͍͠ʂ ΈΜͳ৮ͬͯར༻࣮ྫ૿͑ͯཉ͍͠ʂ