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
Rubyistなら知っておきたい継承の話 / The inheritance for Rubyist
Search
Hiroyuki Morita
July 29, 2018
4
1.4k
Rubyistなら知っておきたい継承の話 / The inheritance for Rubyist
TokyuRuby会議 12
Hiroyuki Morita
July 29, 2018
Tweet
Share
More Decks by Hiroyuki Morita
See All by Hiroyuki Morita
esaを使って暗黙知を減らす取り組み
chiastolite
2
4.1k
git-inside
chiastolite
0
250
vagrant-itamae
chiastolite
1
1.5k
sushi for common people
chiastolite
0
330
Social Coding with GitHub
chiastolite
0
140
Low Level Git
chiastolite
0
92
about Immutable Infrastructure
chiastolite
0
86
Featured
See All Featured
Building Adaptive Systems
keathley
38
2.3k
The Web Performance Landscape in 2024 [PerfNow 2024]
tammyeverts
2
290
How to Ace a Technical Interview
jacobian
276
23k
ReactJS: Keep Simple. Everything can be a component!
pedronauck
665
120k
Code Review Best Practice
trishagee
65
17k
Building a Modern Day E-commerce SEO Strategy
aleyda
38
7k
How to train your dragon (web standard)
notwaldorf
88
5.7k
A Modern Web Designer's Workflow
chriscoyier
693
190k
Writing Fast Ruby
sferik
628
61k
The Illustrated Children's Guide to Kubernetes
chrisshort
48
48k
A Philosophy of Restraint
colly
203
16k
Stop Working from a Prison Cell
hatefulcrawdad
267
20k
Transcript
RubyistͳΒͬͯ ͓͖͍ͨ ܧঝͷ 2018/07/29 TokyuRubyձٞ12 @chiastolite as cͳΜͱ͔e a.k.a ཧແ৬
a.k.a അձһূ
ܧঝͱ?
ܧঝ class Parent # Ϋϥε end class Child < Parent
# ࢠΫϥε end
͔ΒࢠʹҾ͖ܧ͕ΕΔͷʁ
! ! ῡ
Ҩ࢈૬ଓ
Ҩ࢈૬ଓͷجຊ 1. ඃ૬ଓਓͷࡒ࢈ͷࡧ 2. ඃ૬ଓਓͷࡒ࢈ͷׂΛڠٞ 3. (ඞཁͰ͋Ε) ૬ೲ੫ͷೲ
૬ଓ੫ͷਃࠂ
૬ଓ੫ͷਃࠂɾೲ10ϲ݄Ҏ begin start = Time.now if ਃࠂ͕ඞཁ? ਃࠂ ೲ੫ raise
'ظݶΦʔόʔ' if Time.now > start + 10.months end rescue ೲ੫ֹ + ແਃࠂՃࢉ੫ + Ԇ੫ end
ਃࠂͷఆ? جૅ߇আ = 30_000_000 def ਃࠂ͕ඞཁ? ૬ଓֹ > جૅ߇আ +
૬ଓਓ * 6_000_000 end def ૬ଓֹ amount ||= 0 amount += parent.ݱۚ amount += parent.༬ஷۚ amount += parent.ূ݊ amount += parent. amount += parent.ݐ amount += parent.ࣗಈं amount -= parent.࠴ end
૬ଓ੫ͷઅ੫
૬ଓֹΛઅ੫͢Δʹ → ੜલଃ༩ → ॅΒڭҭΒͷࢧԉΛͯ͠Β͏ → ͳͲΛങ͏ͱࢿ࢈ֹ͕ 㽊 → ඇ՝੫ͷࢿ࢈Λങ͏
→ ಛྫΛ͏ →খنͷಛྫ
ͦΕͰӽ͑ͯ͠·ͬͨΒʁ
͖͋ΒΊ·͠ΐ͏ɻਃࠂͩʂ
୭ʹཔΉʁ → ۜߦ → หޢ࢜ → ੫ཧ࢜ → ࢘๏ॻ࢜ →
ߦॻ࢜ ͩΕʹཔΊ͍͍ͷΒ…
!
͜ͷࡍɺࣗͰͬͯ͠·͍͍͑ͷʁ
ͱ͍͏Θ͚ͰͬͯΈͨ → ܭࢉͱ͔هೖྫ͕ͪΌΜͱ͋ΔͷͰ؆୯ → Ձ͕໌֬ͳݱۚ࠷ߴ
ਃࠂͷ໘ͳͱ͜Ζ → खॻ͖ॻྨ࠷ѱ →هೖϛεڐ͞Εͳ͍… → ඃ૬ଓਓͷੜ·Ε͔ͯΒͷށ੶౽ຊूΊ → ਃࠂઌʮඃ૬ଓਓʯͷ࠷ऴډॅ → Ͳ͜ʹݴͬͯʮ͓͑Ͱ͖ͳ͍ʯ
·͍͊Ζ͍Ζ͋Γ·͕ͨ͠
ͳΜͱ͔ͳΔͷ
࠷ޙʹ
ࣄલͷใେࣄ → ށ੶Ͳ͜ʹ͋Γͦ͏ʁ → Ͳͷۚ༥ػؔͬͯΔʁ → ӅΕͨࢿ࢈ͳ͍ʁ
Λฉ͔͕ͤͯΒͦΜͳΛͯ͠Έͯ?