📜  红宝石 |向量 hash()函数

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

红宝石 |向量 hash()函数

hash()是 Ruby 中的内置方法,返回向量的哈希码

示例 1

# Ruby program for hash() method in Vector
     
# Include matrix 
require "matrix"
     
# Initialize the vector
vec1 = Vector[1, 2, 3]
    
# Prints hash code of the vector
puts vec1.hash()

输出

-2830195808542644263

示例 2

# Ruby program for hash() method in Vector
     
# Include matrix 
require "matrix"
     
# Initialize the vector
vec1 = Vector[1, 1, 1]
    
# Prints hash code of the vector
puts vec1.hash()

输出

-3301760512247990187