Ruby | Matrix hash() function Last Updated : 12 Jul, 2025 Summarize Comments Improve Suggest changes Share Like Article Like Report 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] Comment More infoAdvertise with us Next Article Ruby | Hash merge! function G gopaldave Follow Improve Article Tags : Ruby Ruby-Methods Ruby Matrix-class Similar Reads Ruby | Matrix I() function The I() is an inbuilt method in Ruby returns a Identity matrix of N X N size. Syntax: mat1.I(N) Parameters: The function accepts a mandatory parameter N which is the size of the Identity matrix. Return Value: It returns the Identity matrix. Example 1: Ruby # Ruby program for I() method in Matrix # I 1 min read Ruby | Matrix I() function The I() is an inbuilt method in Ruby returns a Identity matrix of N X N size. Syntax: mat1.I(N) Parameters: The function accepts a mandatory parameter N which is the size of the Identity matrix. Return Value: It returns the Identity matrix. Example 1: Ruby # Ruby program for I() method in Matrix # I 1 min read Ruby | Hash merge function Hash#merge() is a Hash class method which combines two hash arrays and their content. Syntax: Hash.merge() Parameter: Hash values Return: combine two hash arrays Example #1 : Ruby # Ruby code for Hash.merge() method # declaring Hash value a = {a:100, b:200} # declaring Hash value b = {a:100, c:300, 2 min read Ruby | Hash merge! function Hash#merge!() : merge!() is a Hash class method which can add the content the given hash array to the other. Entries with duplicate keys are overwritten with the values from each other_hash successively if no block is given. Syntax: Hash.merge!() Parameter: Hash values Return: add the content the gi 2 min read Ruby | Hash member? function Hash#member?() is a Hash class method which checks whether the given key is present in hash is not. Syntax: Hash.member?() Parameter: Hash values Return: true - if given key is present in hash otherwise return false Example #1 : Ruby # Ruby code for Hash.member?() method # declaring Hash value a = { 2 min read Ruby | Regexp hash() function Regexp#force_encoding?() : force_encoding?() is a Regexp class method which returns the hash based on the text and options of this regular expression. Syntax: Regexp.hash() Parameter: Regexp values Return: the hash based on the text and options of this regular expression. Example #1 : Ruby # Ruby co 1 min read Like