0
0

More than 1 year has passed since last update.

100日後くらいに個人開発するぞ!day057

Posted at

今日は継承を学んでみた!

image.png

今日の学び

継承

  • 継承とはあるクラスを元にして新たなクラスをつくること
    • class 新しいクラス名 < 元にするクラス名で他のクラスを継承できる
    • 新しいクラスを「子クラス」、元にするクラスを「親クラス」と呼ぶ
  • 継承すると親クラスのインスタンス変数やインスタンスメソッドを小クラスでも使える

子クラスにインスタンス変数を追加する

  • attr_accessorを用いると子クラスにインスタンス変数を追加することができる
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0