Ruby | Hash values function Last Updated : 07 Jan, 2020 Comments Improve Suggest changes Like Article Like Report Hash#values() is a Hash class method which returns the values present in the hash. Syntax: Hash.values() Parameter: Hash values Return: hash values Example #1 : Ruby # Ruby code for Hash.values() 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} # values Value puts "Hash a values form : #{a.values()}\n\n" puts "Hash b values form : #{b.values()}\n\n" puts "Hash c values form : #{c.values()}\n\n" Output : Hash a values form : [100, 200] Hash b values form : [100, 300, 200] Hash c values form : [100] Example #2 : Ruby # Ruby code for Hash.values() 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} # values Value puts "Hash a values form : #{a.values()}\n\n" puts "Hash b values form : #{b.values()}\n\n" puts "Hash c values form : #{c.values()}\n\n" Output : Hash a values form : [100, 200] Hash b values form : [100] Hash c values form : [100, 300, 200] Comment More infoAdvertise with us Next Article Ruby | Hash values function K Kirti_Mangal Follow Improve Article Tags : Ruby Ruby-Methods Ruby Hash-class Similar Reads Ruby | Hash has_value?() function Hash#has_value?() is a Hash class method which checks whether the given value is present in hash. Syntax: Hash.has_value?() Parameter: Hash values Return: true - if given value is present in hash otherwise return false Example #1 : Ruby # Ruby code for Hash.has_value?() method # declaring Hash value 2 min read Ruby | Hash fetch_values() function Hash#fetch_values() is a Hash class method which returns array containing the values associated with the given keys. With no other arguments, it will raise a KeyError exception. Syntax: Hash.fetch_values() Parameter: Hash values Return: array containing the values associated with the given keys Exam 1 min read 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 # Ruby program for hash() method in Vector # Include matrix require "matrix" # Initia 1 min read Ruby | Hash to_s() function Hash#to_s() is a Hash class method which gives the string representation of hash. Syntax: Hash.to_s() Parameter: Hash values Return: string representation of hash Example #1 : Ruby # Ruby code for Hash.to_s() method # declaring Hash value a = {a:100, b:200} # declaring Hash value b = {a:100, c:300, 1 min read Ruby | Time hash function Time#hash() : hash() is a Time class method which returns the hash code for this Time object. Syntax: Time.hash() Parameter: Time values Return: the hash code for this Time object. Example #1 : Ruby # Ruby code for Time.hash() method # declaring time a = Time.new(2019) # declaring time b = Time.new( 2 min read Like