红宝石 |数字+方法
+是 Ruby 中的一个内置方法,返回两个数字的加法。它返回 a + b。
Syntax: a + b
Parameters: The function needs two number whose addition is returned.
Return Value: It returns the addition of two numbers.
示例 1 :
Ruby
# Ruby program for + method in Numeric
# Initialize two numbers
a = 19
b = 4
# Prints a + b
puts a + b
Ruby
# Ruby program for + method in Numeric
# Initialize two numbers
a = 13
b = 2
# Prints a + b
puts a + b
输出:
23
示例 2 :
红宝石
# Ruby program for + method in Numeric
# Initialize two numbers
a = 13
b = 2
# Prints a + b
puts a + b
输出:
15