📜  红宝石 |矩阵 hash()函数

📅  最后修改于: 2022-05-13 01:54:55.698000             🧑  作者: Mango

红宝石 |矩阵 hash()函数

hash()是 Ruby 中的一个内置方法,它返回矩阵的哈希码。

示例 1

Ruby
# Ruby program for hash() method in Matrix
  
# Include matrix
require "matrix"
 
# Initializes the matrix
mat1 = Matrix[[12, 21], [31, 12]]
  
# Prints the hash-code
puts  mat1.hash()


Ruby
# Ruby program for hash() method in Matrix
  
# Include matrix
require "matrix"
 
# Initializes the matrix
mat1 = Matrix[[6, 7], [9, 10], [12, 4]]
  
# Prints the hash-code
puts  mat1.hash()


输出

631900695216402634

示例 2

红宝石

# Ruby program for hash() method in Matrix
  
# Include matrix
require "matrix"
 
# Initializes the matrix
mat1 = Matrix[[6, 7], [9, 10], [12, 4]]
  
# Prints the hash-code
puts  mat1.hash()

输出

-1308023948917233670]