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
Making the Leap to Tech Lead
cromwellryan
133
9k
GitHub's CSS Performance
jonrohan
1030
460k
A Modern Web Designer's Workflow
chriscoyier
693
190k
"I'm Feeling Lucky" - Building Great Search Experiences for Today's Users (#IAC19)
danielanewman
226
22k
Why You Should Never Use an ORM
jnunemaker
PRO
54
9.1k
Producing Creativity
orderedlist
PRO
341
39k
The Illustrated Children's Guide to Kubernetes
chrisshort
48
48k
[RailsConf 2023 Opening Keynote] The Magic of Rails
eileencodes
28
9.1k
Bash Introduction
62gerente
608
210k
Fantastic passwords and where to find them - at NoRuKo
philnash
50
2.9k
I Don’t Have Time: Getting Over the Fear to Launch Your Podcast
jcasabona
29
2k
Improving Core Web Vitals using Speculation Rules API
sergeychernyshev
0
98
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
૬ଓ੫ͷઅ੫
૬ଓֹΛઅ੫͢Δʹ → ੜલଃ༩ → ॅΒڭҭΒͷࢧԉΛͯ͠Β͏ → ͳͲΛങ͏ͱࢿ࢈ֹ͕ 㽊 → ඇ՝੫ͷࢿ࢈Λങ͏
→ ಛྫΛ͏ →খنͷಛྫ
ͦΕͰӽ͑ͯ͠·ͬͨΒʁ
͖͋ΒΊ·͠ΐ͏ɻਃࠂͩʂ
୭ʹཔΉʁ → ۜߦ → หޢ࢜ → ੫ཧ࢜ → ࢘๏ॻ࢜ →
ߦॻ࢜ ͩΕʹཔΊ͍͍ͷΒ…
!
͜ͷࡍɺࣗͰͬͯ͠·͍͍͑ͷʁ
ͱ͍͏Θ͚ͰͬͯΈͨ → ܭࢉͱ͔هೖྫ͕ͪΌΜͱ͋ΔͷͰ؆୯ → Ձ͕໌֬ͳݱۚ࠷ߴ
ਃࠂͷ໘ͳͱ͜Ζ → खॻ͖ॻྨ࠷ѱ →هೖϛεڐ͞Εͳ͍… → ඃ૬ଓਓͷੜ·Ε͔ͯΒͷށ੶౽ຊूΊ → ਃࠂઌʮඃ૬ଓਓʯͷ࠷ऴډॅ → Ͳ͜ʹݴͬͯʮ͓͑Ͱ͖ͳ͍ʯ
·͍͊Ζ͍Ζ͋Γ·͕ͨ͠
ͳΜͱ͔ͳΔͷ
࠷ޙʹ
ࣄલͷใେࣄ → ށ੶Ͳ͜ʹ͋Γͦ͏ʁ → Ͳͷۚ༥ػؔͬͯΔʁ → ӅΕͨࢿ࢈ͳ͍ʁ
Λฉ͔͕ͤͯΒͦΜͳΛͯ͠Έͯ?