Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Speaker Deck
PRO
Sign in
Sign up for free
Understanding Subtype in 5 Minutes
Ryosuke TAKASHIMA
September 06, 2019
Programming
0
96
Understanding Subtype in 5 Minutes
Ryosuke TAKASHIMA
September 06, 2019
Tweet
Share
More Decks by Ryosuke TAKASHIMA
See All by Ryosuke TAKASHIMA
GCP native cloud migration
rst76
1
270
Cloud migration of the essential service
rst76
1
310
About purely functional language
rst76
0
47
performance-tuning-of-the-microservice.pdf
rst76
0
900
red-black-tree.pdf
rst76
0
34
Fun of Types
rst76
0
22
Embedded Probabilistic Programming
rst76
0
110
Other Decks in Programming
See All in Programming
io22 extended What's new in app performance
veronikapj
0
340
Deep Dive Into Google Zanzibar and its Concepts for Authorization Scenarios
dschenkelman
1
140
"What's new in Swift"の要約 / swift_5_7_summary
uhooi
1
340
1時間半で克服するJavaScriptの非同期処理/async_javascript_kokufuku
marchin1989
2
620
即、New Relic / New Relic NOW!
uzulla
0
330
ES2022の新機能
smt7174
0
260
The strategies behind ddd – AdeoDevSummit 2022
lilobase
PRO
4
250
Java アプリとAWS の良い関係 - AWS でJava アプリを実行する一番簡単な方法教えます / AWS for Javarista
kanamasa
2
1.3k
UI Testing of Jetpack Compose Apps, AppDevCon
alexzhukovich
0
170
シェーダー氷山発掘記
logilabo
0
150
インターン生・新卒向け、学校でもっと教えてほしいITエンジニア基本スキル
nearme_tech
0
130
Beyond Micro Frontends: Frontend Moduliths for the Enterprise @enterjs2022
manfredsteyer
PRO
0
190
Featured
See All Featured
We Have a Design System, Now What?
morganepeng
35
3k
Fantastic passwords and where to find them - at NoRuKo
philnash
27
1.5k
Typedesign – Prime Four
hannesfritz
34
1.4k
A better future with KSS
kneath
225
15k
Agile that works and the tools we love
rasmusluckow
319
19k
Designing for humans not robots
tammielis
241
23k
CoffeeScript is Beautiful & I Never Want to Write Plain JavaScript Again
sstephenson
151
13k
Templates, Plugins, & Blocks: Oh My! Creating the theme that thinks of everything
marktimemedia
15
950
Facilitating Awesome Meetings
lara
29
4k
Adopting Sorbet at Scale
ufuk
63
7.6k
Navigating Team Friction
lara
175
11k
"I'm Feeling Lucky" - Building Great Search Experiences for Today's Users (#IAC19)
danielanewman
212
20k
Transcript
̑ͰΘ͔Δ෦ܕ ΤϜεϦʔ ߴౡ྄༞ʢ@rst76ʣ
ͳͥʁ
෦ܕͱ w ܕͷ্Լʢแؚʣؔ෦ܕؔ w ԼҐͷܕΛ෦ܕͱݺͿ w +BWBͷ߹ɺܧঝͰ࣮ݱ w ܕͷมԽʹͱͳ͏෦ܕؔͷมԽ ෆมɾڞมɾม
Object Number Integer ্Ґͷܕ ԼҐͷܕ ࢠ
෦ܕؔ̍ w ্Ґͷܕ͕ظ͞Ε͍ͯΔͱ͜ΖʹɺԼҐͷܕΛ͏͜ͱͰ͖Δ Function<Object, String> objFunc = o -> o.toString()
+ "!!!"; objFunc.apply(76); // => "76!!!" objFunc.apply("ten"); // => "ten!!!"
෦ܕؔ̎ w ԼҐͷܕ͕ظ͞Ε͍ͯΔͱ͜Ζʹɺ্ҐͷܕΛ͏͜ͱͰ͖ͳ͍ Function<Integer, String> intFunc = i -> Integer.toString(i
/ 2) + "???"; intFunc.apply(76); // => "39???" intFunc.apply(new Object()); // => Compile Error
ؔͷ߹̍ w ؔܕ Function<Function<Number, String>, String> numFuncFunc = f ->
f.apply(76.0); Function<Number, String> numFunc = n -> Integer.toString(n.intValue() / 4) + "..."; numFuncFunc.apply(numFunc); // => "19..."
ؔͷ߹̎ w ҾͰؔ͢ͷҾɺԼҐͷܕʹͰ͖ͳ͍ʂ ؔ͢ɺҾͷܕʹ࿙Εͳ͘ରԠͰ͖Δʢఆ֎Ͱͳ͍ʣඞཁ͕͋Δ Function<Function<Number, String>, String> numFuncFunc = f
-> f.apply(76.0); Function<Integer, String> intFunc = i -> Integer.toString(i * 2) + "???"; numFuncFunc.apply(intFunc); // => CompileError
ؔͷ߹̏ w ٯʹ্ҐͷܕΛҾʹͱΔؔͳΒɾɾɾ Function<Function<? super Number, String>, String> numFuncFunc =
f -> f.apply(76.0); Function<Object, String> objFunc = o -> o.toString() + "!!!"; numFuncFunc.apply(objFunc); // => "76.0!!!"
·ͱΊ w ܕͷ্ԼؔɺؔͷҾͰٯస͢Δˠม w ܕָ͍͠ʂ w ָ͍ؔ͠ʂʂ
એ w ʰϫϯεɾΞϙϯɾΞϯɾΞϧΰϦζϜʱ ɹͱ͍͏ຊΛ༁͠·ͨ͠ w ༗໊ͳөըΛࡐʹɺܭࢉػՊֶΛղઆ͍ͯ͠·͢