Ruby | Hash eql? function Last Updated : 07 Jan, 2020 Comments Improve Suggest changes Like Article Like Report Hash#eql?() is a Hash class method which checks whether the two Hash arrays are equal or not. Syntax: Hash.eql?() Parameter: Hash values Return: true - if two hash arrays are equal otherwise return false Example #1 : Ruby # Ruby code for Hash.eql?() method # declaring Hash value a = {a:100, b:200} # declaring Hash value b = {a:100, c:300, b:200} # declaring Hash value c = {a:100} # equal? Value puts "Hash a equal? form : #{a.eql?(b)}\n\n" puts "Hash b equal? form : #{b.eql?(c)}\n\n" puts "Hash c equal? form : #{c.eql?(a)}\n\n" Output : Hash a equal? form : false Hash b equal? form : false Hash c equal? form : false Example #2 : Ruby # Ruby code for Hash.equal?() method # declaring Hash value a = { "a" => 100, "b" => 200 } # declaring Hash value b = {"a" => 100} # declaring Hash value c = {"a" => 100, "c" => 300, "b" => 200} # equal? Value puts "Hash a equal? form : #{a.eql?(b)}\n\n" puts "Hash b equal? form : #{b.eql?(c)}\n\n" puts "Hash c equal? form : #{c.eql?(a)}\n\n" Output : Hash a equal? form : false Hash b equal? form : false Hash c equal? form : false Comment More infoAdvertise with us Next Article Ruby | Hash fetch function K Kirti_Mangal Follow Improve Article Tags : Ruby Ruby-Methods Ruby Hash-class Similar Reads Ruby | Hash each() function Hash#each() is a Hash class method which finds the nested value which calls block once for each key in hash by passing the key-value pair as parameters. Syntax: Hash.each() Parameter: Hash values Return: calls block once for each key in hash otherwise Enumerator if no argument is passed. Example #1 2 min read Ruby | Hash delete() function delete() is an Hash class method which deletes the key-value pair and returns the value from hash whose key is equal to key. Syntax: Hash.delete() Parameter: Hash array Return: value from hash whose key is equal to deleted key. Example #1: Ruby # Ruby code for delete() method # declaring Hash value 1 min read Ruby | Hash fetch function Hash#fetch() is a Hash class method which returns a value from the hash for the given key. With no other arguments, it will raise a KeyError exception. Syntax: Hash.fetch() Parameter: Hash values Return: value from the hash for the given key Example #1 : Ruby # Ruby code for Hash.fetch() method # de 2 min read Ruby | Hash empty? function Hash#empty?() is a Hash class method which checks whether the Hash array has any key-value pair. Syntax: Hash.empty?()Parameter: Hash valuesReturn: true - if no key value pair otherwise return false Example #1 :  Ruby # Ruby code for Hash.empty?() method # declaring Hash value a = {a:100, b:200} # 1 min read Ruby | Hash clear() function clear() is an Hash class method which removes all the Hash elements from it. Syntax: Hash.clear() Parameter: Hashs to clear off Return: Hash with all elements cleared Example #1: Ruby # Ruby code for clear() method # declaring Hash value a = {a:100, b:200} # declaring Hash value b = {a:100, c:300, b 1 min read Ruby | Hash any?() function any?() is a Hash class method which checks for the presence of a pattern and passes each element of the collection to the given block. Syntax: Hash.any?() Parameter: Hash for testing Return: true - if the block ever returns a value other than false or nil otherwise return false Example #1: Ruby # Ru 1 min read Like