LoginSignup
0
0

More than 3 years have passed since last update.

Ruby メソッド の 定義

Posted at

目的

  • Rubyにてメソッドを自分で定義する方法を記載する。
  • 他の言語で言うところの関数化に近い機能をまとめる。

書き方の例

  • 繰り返し使用する処理をメソッド化することでコードの総ステップ数を削減することができる。
  • 下記にメソッドの定義方法を記載する。
def メソッド名
  処理内容
end

より具体的な例

  • 「hello」と出力するメソッドを作成する。
  • メソッド名はoutput_helloとする。
  • 下記にメソッドの定義方法を記載する。
def output_hello
  puts "hello"
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