0
0

More than 1 year has passed since last update.

Rubyのincludeについて

Posted at

はじめに

※以下の内容には誤りが含まれる可能性があります

includeとは

includeはモジュールの性質を他のクラスに追加するために使用されるメソッドです。

簡単に言うとincludeはモジュールを呼ぶためのメソッドです。

includeの使い方

書き方は基本的にクラスと同じに、モジュールを定義し、

その中にメソッドを記述します。

module モジュール名
def メソッド名()
メソッドの機能
end
end

そうしたらクラスの中でincludeでモジュールを指定し、モジュールに記載されたメソッドをクラスに取り込みます。

まとめ

  • includeはモジュールを呼ぶためのメソッド
  • 書き方は
module モジュール名
def メソッド名()
メソッドの機能
end
end
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