红宝石 |整数 + 方法
+是 Ruby 中的一个内置方法,返回两个数字的加法。它返回 num1 + num2。
Syntax: num1 + num2
Parameters: The function accepts no parameter.
Return Value: It returns the addition of two numbers.
示例 1 :
# Ruby program for + method in Integer
# Initialize numbers
num1 = 15
num2 = 4
# Prints addition
print num1 + num2
输出:
19
示例 2 :
# Ruby program for + method in Integer
# Initialize numbers
num1 = 21
num2 = 3
# Prints addition
print num1 + num2
输出:
24