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
240
vagrant-itamae
chiastolite
1
1.5k
sushi for common people
chiastolite
0
320
Social Coding with GitHub
chiastolite
0
140
Low Level Git
chiastolite
0
90
about Immutable Infrastructure
chiastolite
0
86
Featured
See All Featured
Designing for Performance
lara
604
68k
The Pragmatic Product Professional
lauravandoore
31
6.3k
Building Applications with DynamoDB
mza
90
6.1k
Let's Do A Bunch of Simple Stuff to Make Websites Faster
chriscoyier
506
140k
Done Done
chrislema
181
16k
JavaScript: Past, Present, and Future - NDC Porto 2020
reverentgeek
47
5k
BBQ
matthewcrist
85
9.3k
Templates, Plugins, & Blocks: Oh My! Creating the theme that thinks of everything
marktimemedia
26
2.1k
Code Review Best Practice
trishagee
64
17k
The Cult of Friendly URLs
andyhume
78
6k
Producing Creativity
orderedlist
PRO
341
39k
Fight the Zombie Pattern Library - RWD Summit 2016
marcelosomers
232
17k
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
૬ଓ੫ͷઅ੫
૬ଓֹΛઅ੫͢Δʹ → ੜલଃ༩ → ॅΒڭҭΒͷࢧԉΛͯ͠Β͏ → ͳͲΛങ͏ͱࢿ࢈ֹ͕ 㽊 → ඇ՝੫ͷࢿ࢈Λങ͏
→ ಛྫΛ͏ →খنͷಛྫ
ͦΕͰӽ͑ͯ͠·ͬͨΒʁ
͖͋ΒΊ·͠ΐ͏ɻਃࠂͩʂ
୭ʹཔΉʁ → ۜߦ → หޢ࢜ → ੫ཧ࢜ → ࢘๏ॻ࢜ →
ߦॻ࢜ ͩΕʹཔΊ͍͍ͷΒ…
!
͜ͷࡍɺࣗͰͬͯ͠·͍͍͑ͷʁ
ͱ͍͏Θ͚ͰͬͯΈͨ → ܭࢉͱ͔هೖྫ͕ͪΌΜͱ͋ΔͷͰ؆୯ → Ձ͕໌֬ͳݱۚ࠷ߴ
ਃࠂͷ໘ͳͱ͜Ζ → खॻ͖ॻྨ࠷ѱ →هೖϛεڐ͞Εͳ͍… → ඃ૬ଓਓͷੜ·Ε͔ͯΒͷށ੶౽ຊूΊ → ਃࠂઌʮඃ૬ଓਓʯͷ࠷ऴډॅ → Ͳ͜ʹݴͬͯʮ͓͑Ͱ͖ͳ͍ʯ
·͍͊Ζ͍Ζ͋Γ·͕ͨ͠
ͳΜͱ͔ͳΔͷ
࠷ޙʹ
ࣄલͷใେࣄ → ށ੶Ͳ͜ʹ͋Γͦ͏ʁ → Ͳͷۚ༥ػؔͬͯΔʁ → ӅΕͨࢿ࢈ͳ͍ʁ
Λฉ͔͕ͤͯΒͦΜͳΛͯ͠Έͯ?