Ruby | Matrix hash() function
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
# 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() |
Output:
631900695216402634
Example 2:
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() |
Output:
-1308023948917233670]