1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Ruby勉強日誌3

Posted at

クラス

class.rb
   class ◯◯◯◯◯
     attr_accessor :□□□, :△△△
   end

インスタンス

instance.rb
   変数 = クラス名.new
   変数.属性 = ✖️✖︎
   puts 変数.属性

インスタンス変数:名前が@で始まる変数

initializeメソッド:インスタンス作成時の初期値を設定

initialize.rb
   class BillRecord 
   attr_accessor :name, :bill
   def initialize(name, bill)
     @name = name
     @bill = bill
    end
   end
   data = BillRecord.new("◯◯","✖︎✖︎")
1
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
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?