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
250
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.6k
App hibernation🥶
operando
0
280
できる!Android Framework Code Reading
operando
1
810
設定だけでCircleCIの実行時間を短縮できるかもしれない話
operando
0
270
スタートアップ再びの一年と知の探索
operando
0
670
ピースオブケイクでのZapier活用術
operando
1
1.3k
Other Decks in Technology
See All in Technology
kargoの魅力について伝える
magisystem0408
0
210
Storage Browser for Amazon S3
miu_crescent
1
220
サーバレスアプリ開発者向けアップデートをキャッチアップしてきた #AWSreInvent #regrowth_fuk
drumnistnakano
0
200
Qiita埋め込み用スライド
naoki_0531
0
5.1k
組織に自動テストを書く文化を根付かせる戦略(2024冬版) / Building Automated Test Culture 2024 Winter Edition
twada
PRO
17
4.7k
[Ruby] Develop a Morse Code Learning Gem & Beep from Strings
oguressive
1
170
ゼロから創る横断SREチーム 挑戦と進化の軌跡
rvirus0817
2
270
WACATE2024冬セッション資料(ユーザビリティ)
scarletplover
0
210
大幅アップデートされたRagas v0.2をキャッチアップ
os1ma
2
540
Amazon Kendra GenAI Index 登場でどう変わる? 評価から学ぶ最適なRAG構成
naoki_0531
0
120
10分で学ぶKubernetesコンテナセキュリティ/10min-k8s-container-sec
mochizuki875
3
350
小学3年生夏休みの自由研究「夏休みに Copilot で遊んでみた」
taichinakamura
0
170
Featured
See All Featured
Music & Morning Musume
bryan
46
6.2k
The Cost Of JavaScript in 2023
addyosmani
45
7k
Side Projects
sachag
452
42k
Automating Front-end Workflow
addyosmani
1366
200k
CoffeeScript is Beautiful & I Never Want to Write Plain JavaScript Again
sstephenson
159
15k
The Illustrated Children's Guide to Kubernetes
chrisshort
48
48k
jQuery: Nuts, Bolts and Bling
dougneiner
61
7.5k
A better future with KSS
kneath
238
17k
Creating an realtime collaboration tool: Agile Flush - .NET Oxford
marcduiker
26
1.9k
[Rails World 2023 - Day 1 Closing Keynote] - The Magic of Rails
eileencodes
33
2k
Code Review Best Practice
trishagee
65
17k
Designing for humans not robots
tammielis
250
25k
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!