红宝石 |数字共轭()函数
conjugate()是 Ruby 中的一个内置方法,它返回数字本身。
Syntax: num1.conjugate()
Parameters: The function needs a number.
Return Value: It returns itself only.
示例 1 :
# Ruby program for conjugate() method in Matrix
# Initialize a number
num1 = 1.7
# Function used
num = num1.conjugate()
# Prints conjugate() of num
puts num
输出:
1.7
示例 2 :
# Ruby program for conjugate() method in Matrix
# Initialize a number
num1 = 19
# Function used
num = num1.conjugate()
# Prints conjugate() of num
puts num
输出:
19