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
Understanding Subtype in 5 Minutes
Search
Sponsored
·
SiteGround - Reliable hosting with speed, security, and support you can count on.
→
Ryosuke TAKASHIMA
September 06, 2019
Programming
190
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Understanding Subtype in 5 Minutes
Ryosuke TAKASHIMA
September 06, 2019
More Decks by Ryosuke TAKASHIMA
See All by Ryosuke TAKASHIMA
GCP native cloud migration
rst76
1
550
Cloud migration of the essential service
rst76
1
620
About purely functional language
rst76
0
160
performance-tuning-of-the-microservice.pdf
rst76
0
1.6k
red-black-tree.pdf
rst76
0
94
Fun of Types
rst76
0
63
Embedded Probabilistic Programming
rst76
0
390
Other Decks in Programming
See All in Programming
Composerを使ったサプライチェーン攻撃の様子を眺めてみる #phpstudy
o0h
PRO
2
220
RTSPクライアントを自作してみた話
simotin13
0
490
Old Dog, New Tricks: The Java 25 Reinvention - JNation
bazlur_rahman
0
150
Lemonade + Foundry Toolkit でお手軽アプリ開発
seosoft
1
310
AI駆動開発で崩れていくコードベースを立て直す
kyoko_nr_nr
1
440
Semantic Version 単位で戦略を柔軟に変えて、パッケージアップデートを自動化する
daitasu
0
160
New "Type" system on PicoRuby
pocke
1
470
代数的データ型って何が嬉しいの? #frontend_phpcon_do
kajitack
8
3.2k
dRuby over BLE
makicamel
2
320
運用エージェントは "作る" から "育てる" へ - 記憶と自己進化の3層設計パターン / self-evolving-agents-three-layer-agent-design
gawa
12
3.5k
GitHub Copilot CLIのいいところ
htkym
2
1.3k
Oxcを導入して開発体験が向上した話
yug1224
4
290
Featured
See All Featured
Ten Tips & Tricks for a 🌱 transition
stuffmc
0
130
RailsConf & Balkan Ruby 2019: The Past, Present, and Future of Rails at GitHub
eileencodes
141
35k
Connecting the Dots Between Site Speed, User Experience & Your Business [WebExpo 2025]
tammyeverts
11
940
Being A Developer After 40
akosma
91
590k
JAMstack: Web Apps at Ludicrous Speed - All Things Open 2022
reverentgeek
1
460
個人開発の失敗を避けるイケてる考え方 / tips for indie hackers
panda_program
122
22k
New Earth Scene 8
popppiees
3
2.3k
The SEO Collaboration Effect
kristinabergwall1
1
480
実際に使うSQLの書き方 徹底解説 / pgcon21j-tutorial
soudai
PRO
201
75k
Claude Code どこまでも/ Claude Code Everywhere
nwiizo
65
56k
From Legacy to Launchpad: Building Startup-Ready Communities
dugsong
0
220
Building a Modern Day E-commerce SEO Strategy
aleyda
45
9.1k
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 ༗໊ͳөըΛࡐʹɺܭࢉػՊֶΛղઆ͍ͯ͠·͢