LoginSignup
1
0

More than 5 years have passed since last update.

Ruby メソッド書き方

Last updated at Posted at 2018-08-08

メソッド定義式 例

def hello(names)
    names.each do |name|
        puts "Hello,#{name.upcase}"
    end
end

colors = ["red","blue","green"]

hello(colors)

#結果
Hello,RED
Hello,BLUE
Hello,GREEN

def メソッド名(仮引数...)...end
helloメソッドが、hello(colors)によって呼び出されている。

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