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
operandoOS
December 09, 2016
Technology
1
240
Kotlinでマッチョ💪💪💪💪💪する話
Kotlinでマッチョ💪💪💪💪💪する話
Retty Tech Cafe #8
https://retty.connpass.com/event/45628/
operandoOS
December 09, 2016
Tweet
Share
More Decks by operandoOS
See All by operandoOS
Flutter ランチ #2
operando
0
150
Flutter ランチ #1
operando
0
110
10XでのZapier活用事例の紹介
operando
0
1.1k
CircleCIでtiming dataに基づいたテスト分割をDartで利用できるようにした話.
operando
3
2.5k
App hibernation🥶
operando
0
270
できる!Android Framework Code Reading
operando
1
800
設定だけでCircleCIの実行時間を短縮できるかもしれない話
operando
0
270
スタートアップ再びの一年と知の探索
operando
0
660
ピースオブケイクでのZapier活用術
operando
1
1.2k
Other Decks in Technology
See All in Technology
エンジニアが一生困らない ドキュメント作成の基本
naohiro_nakata
3
160
サイバーセキュリティと認知バイアス:対策の隙を埋める心理学的アプローチ
shumei_ito
0
370
SREによる隣接領域への越境とその先の信頼性
shonansurvivors
2
460
State of Open Source Web Mapping Libraries
dayjournal
0
240
ドメイン名の終活について - JPAAWG 7th -
mikit
32
19k
Terraform未経験の御様に対してどの ように導⼊を進めていったか
tkikuchi
2
370
組み込みLinuxの時系列
puhitaku
4
1.1k
Intuneお役立ちツールのご紹介
sukank
3
770
Microsoft Intune アプリのトラブルシューティング
sophiakunii
1
430
RubyのWebアプリケーションを50倍速くする方法 / How to Make a Ruby Web Application 50 Times Faster
hogelog
2
870
スクラムチームを立ち上げる〜チーム開発で得られたもの・得られなかったもの〜
ohnoeight
2
330
データの信頼性を支える仕組みと技術
chanyou0311
6
1.7k
Featured
See All Featured
Into the Great Unknown - MozCon
thekraken
32
1.5k
Refactoring Trust on Your Teams (GOTO; Chicago 2020)
rmw
31
2.7k
Java REST API Framework Comparison - PWX 2021
mraible
PRO
28
8.2k
Become a Pro
speakerdeck
PRO
25
5k
Code Review Best Practice
trishagee
64
17k
[RailsConf 2023 Opening Keynote] The Magic of Rails
eileencodes
28
9.1k
[RailsConf 2023] Rails as a piece of cake
palkan
51
4.9k
Practical Tips for Bootstrapping Information Extraction Pipelines
honnibal
PRO
10
700
Fashionably flexible responsive web design (full day workshop)
malarkey
405
65k
YesSQL, Process and Tooling at Scale
rocio
168
14k
Designing Experiences People Love
moore
138
23k
The Art of Programming - Codeland 2020
erikaheidi
52
13k
Transcript
KotlinͰ Ϛονϣ ͢Δ Retty Tech Cafe #8
About Me Shinobu Okano @operandoOS Mercari, Inc. Souzoh, Inc.
None
ຖ30 Kotlinͬͯ·͢ • ࡶʹࡶʹϝϞΛͯ͠·͢ • http://hack-it-iron.hatenablog.com/archive/ category/Kotlin
Tuple ෳݸͷΛΈʹͯ͠·ͱΊͨͷ
Α͏ Ұ࣌తͳείʔϓͰෳݸͷσʔλͷΈ߹Θ͕ͤ ཉ͍͚͠ͲɺClassΛఆٛ͢Δ΄ͲͰͳ͍ͳʔ ͬͯ࣌ʹ༗ޮ
Guild https://github.com/operando/Guild/ Simple java tuples.
ͳͥTuple͕ඞཁ͔ͩͬͨ • Android + JSON-RPC • http://www.slideshare.net/shinobuokano7/ android-jsonrpc • ཧ༝ॻ͍ͯ͋Δ͔ʁ
KotlinͷPair val pair = 1 to "pair" println(pair.first) // 1
println(pair.second) // pair
Triple͋ΔΑ val triple = Triple(1, true, "Triple") println(triple.first) // 1
println(triple.second) // true println(triple.third) // Triple
͜ΕΛΈ͓ͯͬͨ
͜͏ॻ͚ͳ͍ͷʁ val triple = 1 to true to "Triple"
͜͏ॻ͚ͳ͍ͷʁ val triple = A to B to C
ͦͷ··Ͱॻ͚ͳʔ͍ • Pair in Pairʹͳͬͯ͠·͏ • Pair<Pair<A,B>,C> • ((1,true)"Triple")
ͳʔΜͩɺΧοίΘΔ͍
ͦͦ Pairͷtoͬͯ Ͳ͏ͳͬͯΔΜͩ?
ͦͦ PairͷtoͬͯͲ͏ͳͬͯΔΜͩ? public infix fun <A, B> <A, B>.to(that: B)
: Pair<A, B> = Pair(this, that)
ͳΔ΄Ͳ
͍ɺ·ͯΑ
ಉ͡Α͏ʹ֦ுؔ ࡞ΕͰ͖Δ͔☺
Pair͔ΒTripleΛ࡞Δ֦ுؔΛॻ͍ͯΈͨ infix fun <A, B, C> Pair<A, B>.to(that: C) :
Triple<A, B, C> = Triple(this.first, this.second, that)
͡ΌtoͰͭͳ͛ͯ ॻ͍ͯΈΑ͏
͡ΌtoͰͭͳ͛ͯॻ͍ͯΈΑ͏ val triple = 1 to true to "Triple" println(triple.first)
// 1 println(triple.second) // true println(triple.third) // Triple println(triple.javaClass) // class kotlin.Triple
Ͱ͖ͨ☺
ͬͱϚοεϧ ͍ͨ͠Ͱ͠ΐʁ
4ͭͷΛ࣋ͭ Tuple QuartetΛ࡞Ζ͏
4ͭͷΛ࣋ͭTuple QuartetΛ࡞Ζ͏ class Quartet<out F, out S, out T, out
FO>( val first: F, val second: S, val third: T, val fourth: FO,) { override fun toString(): String { return "Quartet(first=$first, second=$second, third=$third, fourth=$fourth)" } }
toͭͳ͗ͰQuartetΛ ࡞ΕΔΑ͏ʹ͢Δ
Triple͔ΒQuartetΛ࡞Δ֦ுؔΛॻ͘ infix fun <A, B, C, D> Triple<A, B, C>.to(that:
D): Quartet<A, B, C, D> = Quartet(this.first, this.second, this.third, that)
QuartetͬͯΈΑ͏ val quartet = 1 to 10L to true to
"quartet" println(quartet.first) // 1 println(quartet.second) // 10 println(quartet.third) // true println(quartet.fourth) // quartet
ͬͱϚοεϧ ΄͘͠ͳ͍??
5ͭͷΛ࣋ͭ Tuple QuintetΛ࡞Ζ͏
5ͭͷΛ࣋ͭTuple QuintetΛ࡞Ζ͏ class Quintet<out F, out S, out T, out
FO, out FI>( val first: F, val second: S, val third: T, val fourth: FO, val five: FI) { override fun toString(): String { return "Quintet(first=$first, second=$second, third=$third, fourth=$fourth, five=$five)" } }
͍͍ɺtoΛͭͳ͛ͯ ॻ͍ͯ࡞Γ͍ͨΑͶ
͍͍ɺ֦ு֦ؔுؔ infix fun <A, B, C, D, E> Quartet<A, B,
C, D>.to(that: E): Quintet<A, B, C, D, E> = Quintet(this.first, this.second, this.third, this.fourth, that)
QuintetͬͯΈΑ͏ val quintet = 1 to 10L to true to
LocalDateTime.now() to "quintet" println(quintet.first) // 1 println(quintet.second) // 10 println(quintet.third) // true println(quintet.fourth) // 2016-12-09T19:45:38.959 println(quintet.five) // quintet
Libraryʹ͠·ͨ͠
Guild Kotlin https://github.com/operando/Guild/ tree/master/guild-kotlin ͍͔ͭjCenterͱ͔ʹ͋͛·ʔ͢
Links • Pair͔ΒTripleΛ࡞Δ֦ுؔΛॻ͍ͯΈͨ - 2016/12/03ͷ30 KotlinϝϞ • http://hack-it-iron.hatenablog.com/entry/2016/12/03/165601 • 4ͭͱ5ͭΛ࣋ͭTupleΛ࡞ͬͯΈͨ
- 2016/12/04ͷ30 KotlinϝϞ • http://hack-it-iron.hatenablog.com/entry/2016/12/04/223509 • TupleϥΠϒϥϦ GuildͷKotlin൛࡞ͬͯΈͨ - 2016/12/09ͷ30 KotlinϝϞ • http://hack-it-iron.hatenablog.com/entry/2016/12/09/172657 • Guild • https://github.com/operando/Guild/
Thanks!