Skip to content
Related Articles

Related Articles

Ruby | Matrix hash() function
  • Last Updated : 07 Jan, 2020

The hash() is an inbuilt method in Ruby returns the hash-code of the matrix.

Syntax: mat1.hash()

Parameters: The function does not accepts any parameter.

Return Value: It returns the hash-code of the matrix.

Example 1:






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

Output:

631900695216402634

Example 2:




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

Output:

-1308023948917233670]

Attention reader! Don’t stop learning now. Get hold of all the important DSA concepts with the DSA Self Paced Course at a student-friendly price and become industry ready.

My Personal Notes arrow_drop_up
Recommended Articles
Page :