LoginSignup
0
0

More than 3 years have passed since last update.

【Ruby】 かけ算メソッド

Last updated at Posted at 2021-01-29

【コード】

def Multiplication (a, b)
 puts a * b
end

Multiplication(8, 9)

【出力結果】

72

【解説】
test.rbファイルを作成し、
メソッドMaltiplication(英語でかけ算の意)を定義して、(仮引数a,b)に数値を渡し、メソッド内の実行したい処理 puts a * bで出力します。

実引数Multiplication(数値,数値)の数値に値を入力すると、かけ算の結果を得ることが出来ます。

VSコードのRails環境では、ターミナルにてruby test.rbで実行することが出来ます。

*defはDeginition(定義の略)

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