狠狠撸

狠狠撸Share a Scribd company logo
たいやきつくるよ
@carotene4035
今ありそうな悩み
? クラス、インスタンスの概念、
わかったようなわからないような
? 実際にクラスをかいたり、インスタンスを生成
するのって、コード上ではどう書くの?
? 例え话饱きてきた
「たいやき」をつくって解决
おしながき
1.たいやきクラスを作成
2.たいやきインスタンスを3つ生成
3.インスタンスからメソッド呼び出し
4.クラスとインスタンスの関係を図で理解
1.たいやきクラスを作成
? たいやきの最低限の情報
– 中身がある
? この内容でクラスを书いてみる
たいやきクラス
class Taiyaki
# 中身を入れる
def initialize(nakami)
@nakami = nakami
end
# 中身の呼び出し
def getNakami
p @nakami
end
end
たいやきクラス
class Taiyaki
# 中身を入れる
def initialize(nakami)
@nakami = nakami
end
# 中身の呼び出し
def getNakami
p @nakami
end
end
焼く
2.たいやきインスタンスの生成
# たいやきインスタンス1の生成
taiyaki1 = Taiyaki.new('anko’)
# たいやきインスタンス2の生成
taiyaki2 = Taiyaki.new('cream’)
# たいやきインスタンス3の生成
taiyaki3 = Taiyaki.new('chocolate’)
2.たいやきインスタンスの生成
# たいやきインスタンス1の生成
taiyaki1 = Taiyaki.new('anko’)
# たいやきインスタンス2の生成
taiyaki2 = Taiyaki.new('cream’)
# たいやきインスタンス3の生成
taiyaki3 = Taiyaki.new('chocolate’)
3.メソッド呼び出し
# たいやき1の中身確認
taiyaki1.getNakami
# たいやき2の中身確認
taiyaki2.getNakami
# たいやき3の中身確認
taiyaki3.getNakami
3.メソッド呼び出し
# たいやき1の中身確認
taiyaki1.getNakami => “anko”
# たいやき2の中身確認
taiyaki2.getNakami => “cream”
# たいやき3の中身確認
taiyaki3.getNakami => “chocolate”
3.メソッド呼び出し
# たいやき1の中身確認
taiyaki1.getNakami => “anko”
# たいやき2の中身確認
taiyaki2.getNakami => “cream”
# たいやき3の中身確認
taiyaki3.getNakami => “chocolate”
4.図で理解
4.図で理解(叠濒辞驳)
まとめ
? 実際にクラスを作ってインスタンス化すると
よくわかるよ
? べつにたいやきじゃなくても良いよ
なんでもよいよ
お世話になりました
? http://www.itsenka.com/contents/developme
nt/uml/class.html
? http://www.itmedia.co.jp/im/articles/0301/08
/news001.html
? https://cacoo.com/
? http://www.rubylife.jp/ini/class/index5.html
? http://tdak.hateblo.jp/entry/20140406/13967
73476
Ad

Recommended

Vuejs meetup
Vuejs meetup
Kamimura Taichi
?
ruby 関数化のメリット
ruby 関数化のメリット
Kamimura Taichi
?
补箩补虫ってなんなの
补箩补虫ってなんなの
Kamimura Taichi
?
わからないことか?わからないときにどうしたらよいのか。
わからないことか?わからないときにどうしたらよいのか。
Kamimura Taichi
?
Session管理とRailsのcookie store
Session管理とRailsのcookie store
Kamimura Taichi
?
git addの解説
git addの解説
Kamimura Taichi
?
Ansible roleとinventoryの書き方
Ansible roleとinventoryの書き方
Kamimura Taichi
?
惫颈尘入门
惫颈尘入门
Kamimura Taichi
?
2024 Trend Updates: What Really Works In SEO & Content Marketing
2024 Trend Updates: What Really Works In SEO & Content Marketing
Search Engine Journal
?
Storytelling For The Web: Integrate Storytelling in your Design Process
Storytelling For The Web: Integrate Storytelling in your Design Process
Chiara Aliotta
?
Artificial Intelligence, Data and Competition – SCHREPEL – June 2024 OECD dis...
Artificial Intelligence, Data and Competition – SCHREPEL – June 2024 OECD dis...
OECD Directorate for Financial and Enterprise Affairs
?
How to Leverage AI to Boost Employee Wellness - Lydia Di Francesco - SocialHR...
How to Leverage AI to Boost Employee Wellness - Lydia Di Francesco - SocialHR...
SocialHRCamp
?
2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot
Marius Sescu
?
Everything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPT
Expeed Software
?
Product Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage Engineerings
Pixeldarts
?
How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental Health
ThinkNow
?
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
marketingartwork
?
Skeleton Culture Code
Skeleton Culture Code
Skeleton Technologies
?
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024
Neil Kimberley
?
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)
contently
?
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024
Albert Qian
?
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
Kurio // The Social Media Age(ncy)
?
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024
Search Engine Journal
?
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary
SpeakerHub
?
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd
Clark Boyd
?
Getting into the tech field. what next
Getting into the tech field. what next
Tessa Mero
?
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Lily Ray
?
How to have difficult conversations
How to have difficult conversations
Rajiv Jayarajah, MAppComm, ACC
?

More Related Content

Featured (20)

2024 Trend Updates: What Really Works In SEO & Content Marketing
2024 Trend Updates: What Really Works In SEO & Content Marketing
Search Engine Journal
?
Storytelling For The Web: Integrate Storytelling in your Design Process
Storytelling For The Web: Integrate Storytelling in your Design Process
Chiara Aliotta
?
Artificial Intelligence, Data and Competition – SCHREPEL – June 2024 OECD dis...
Artificial Intelligence, Data and Competition – SCHREPEL – June 2024 OECD dis...
OECD Directorate for Financial and Enterprise Affairs
?
How to Leverage AI to Boost Employee Wellness - Lydia Di Francesco - SocialHR...
How to Leverage AI to Boost Employee Wellness - Lydia Di Francesco - SocialHR...
SocialHRCamp
?
2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot
Marius Sescu
?
Everything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPT
Expeed Software
?
Product Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage Engineerings
Pixeldarts
?
How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental Health
ThinkNow
?
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
marketingartwork
?
Skeleton Culture Code
Skeleton Culture Code
Skeleton Technologies
?
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024
Neil Kimberley
?
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)
contently
?
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024
Albert Qian
?
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
Kurio // The Social Media Age(ncy)
?
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024
Search Engine Journal
?
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary
SpeakerHub
?
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd
Clark Boyd
?
Getting into the tech field. what next
Getting into the tech field. what next
Tessa Mero
?
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Lily Ray
?
How to have difficult conversations
How to have difficult conversations
Rajiv Jayarajah, MAppComm, ACC
?
2024 Trend Updates: What Really Works In SEO & Content Marketing
2024 Trend Updates: What Really Works In SEO & Content Marketing
Search Engine Journal
?
Storytelling For The Web: Integrate Storytelling in your Design Process
Storytelling For The Web: Integrate Storytelling in your Design Process
Chiara Aliotta
?
How to Leverage AI to Boost Employee Wellness - Lydia Di Francesco - SocialHR...
How to Leverage AI to Boost Employee Wellness - Lydia Di Francesco - SocialHR...
SocialHRCamp
?
2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot
Marius Sescu
?
Everything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPT
Expeed Software
?
Product Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage Engineerings
Pixeldarts
?
How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental Health
ThinkNow
?
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
marketingartwork
?
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024
Neil Kimberley
?
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)
contently
?
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024
Albert Qian
?
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024
Search Engine Journal
?
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary
SpeakerHub
?
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd
Clark Boyd
?
Getting into the tech field. what next
Getting into the tech field. what next
Tessa Mero
?
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Lily Ray
?

Ruby - オブジェクト指向入門