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
社外コミュニティで学び社内に活かす共に学ぶプロジェクトの実践/backlogworld2024
nishiuma
0
270
20241220_S3 tablesの使い方を検証してみた
handy
4
630
10分で学ぶKubernetesコンテナセキュリティ/10min-k8s-container-sec
mochizuki875
3
360
私なりのAIのご紹介 [2024年版]
qt_luigi
1
120
権威ドキュメントで振り返る2024 #年忘れセキュリティ2024
hirotomotaguchi
2
760
.NET 9 のパフォーマンス改善
nenonaninu
0
1k
KnowledgeBaseDocuments APIでベクトルインデックス管理を自動化する
iidaxs
1
270
[Ruby] Develop a Morse Code Learning Gem & Beep from Strings
oguressive
1
170
社内イベント管理システムを1週間でAKSからACAに移行した話し
shingo_kawahara
0
190
20241214_WACATE2024冬_テスト設計技法をチョット俯瞰してみよう
kzsuzuki
3
590
非機能品質を作り込むための実践アーキテクチャ
knih
5
1.5k
マルチプロダクト開発の現場でAWS Security Hubを1年以上運用して得た教訓
muziyoshiz
3
2.4k
Featured
See All Featured
Testing 201, or: Great Expectations
jmmastey
40
7.1k
Bash Introduction
62gerente
608
210k
Building Flexible Design Systems
yeseniaperezcruz
327
38k
A designer walks into a library…
pauljervisheath
204
24k
What's in a price? How to price your products and services
michaelherold
243
12k
Music & Morning Musume
bryan
46
6.2k
How To Stay Up To Date on Web Technology
chriscoyier
789
250k
The Illustrated Children's Guide to Kubernetes
chrisshort
48
48k
Dealing with People You Can't Stand - Big Design 2015
cassininazir
365
25k
Easily Structure & Communicate Ideas using Wireframe
afnizarnur
191
16k
A Philosophy of Restraint
colly
203
16k
Unsuck your backbone
ammeep
669
57k
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!