红宝石 |数值矩形()函数
rectangle()是 Ruby 中的一个内置方法,它返回一个由实数和虚数组成的数组。
Syntax: num.rectangular()
Parameters: The function needs the number whose real and imaginary part is returned.
Return Value: It returns an array which consists of a real and an imaginary number.
示例 1 :
# Ruby program for rectangular()
# method in Numeric
# Initialize a number
num = Complex(10, 6)
# Prints the rectangular part
puts num.rectangular()
输出:
10
6
示例 2 :
# Ruby program for rectangular()
# method in Numeric
# Initialize a number
num = Complex(18, 16)
# Prints the rectangular part
puts num.rectangular()
输出:
18
16