Horje
Ruby | Vector hash() function

The hash() is an inbuilt method in Ruby returns hash code of the vector

Syntax: vec1.hash()

Parameters: The function accepts no parameter.

Return Value: It returns hash code of the vector.

Example 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()

Output:

-2830195808542644263

Example 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()

Output:

-3301760512247990187



Reffered: https://www.geeksforgeeks.org


Ruby

Related
Ruby | Matrix component() function Ruby | Matrix component() function
Ruby | Matrix column_vectors() function Ruby | Matrix column_vectors() function
Ruby | Matrix column_size() function Ruby | Matrix column_size() function
Ruby | Matrix column() function Ruby | Matrix column() function
Ruby | Matrix column_count() function Ruby | Matrix column_count() function

Type:
Geek
Category:
Coding
Sub Category:
Tutorial
Uploaded by:
Admin
Views:
9