Ruby | Hash value? method Last Updated : 02 Dec, 2021 Comments Improve Suggest changes Like Article Like Report Hash#value?() is a Hash class method which checks whether the argumented 'value' is present in the array or not. Syntax: Hash.value?()Parameter: Hash value?Return: true - if argumented 'value' is present in the array otherwise return false Example #1 : Ruby # Ruby code for Hash.value?() 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} # value? Value puts "Hash a value? form : #{a.value?(200)}\n\n" puts "Hash b value? form : #{b.value?(100)}\n\n" puts "Hash c value? form : #{c.value?(300)}\n\n" Output : Hash a value? form : true Hash b value? form : true Hash c value? form : false Example #2 : Ruby # Ruby code for Hash.value?() 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} # value? Value puts "Hash a value? form : #{a.value?(200)}\n\n" puts "Hash b value? form : #{b.value?(200)}\n\n" puts "Hash c value? form : #{c.value?(300)}\n\n" Output : Hash a value? form : true Hash b value? form : false Hash c value? form : true Comment More infoAdvertise with us Next Article Ruby | Hash select() method K Kirti_Mangal Follow Improve Article Tags : Ruby Ruby-Methods Ruby Hash-class Similar Reads Ruby | Hash values_at method Hash#values_at() is a Hash class method which returns the array containing the values corresponding to keys. Syntax: Hash.values_at() Parameter: Hash values_at Return: array containing the values corresponding to keys. Example #1 : Ruby # Ruby code for Hash.values_at() method # declaring Hash value 1 min read Ruby | Hash select() method Hash#select() : select() is a Hash class method which finds the array from the hash based on the block condition. Syntax: Hash.select() Parameter: Hash values block condition Return: array from the hash based on the block condition. Example #1 : Ruby # Ruby code for Hash.select() method # declaring 1 min read Ruby | Hash select!() method Hash#select!() is a Hash class method which checks whether the array from the hash ius present based on the block condition. Syntax: Hash.select!() Parameter: Hash values block condition Return: array from the hash is present based on the block condition otherwise return false Example #1 : Ruby # Ru 1 min read Ruby | Hash size() method Hash#size() is a Hash class method which returns the count of key-value pair in the hash. Syntax: Hash.size() Parameter: Hash values Return: count of key-value pair in the hash. Example #1 : Ruby # Ruby code for Hash.size() method # declaring Hash value a = {a:100, b:200} # declaring Hash value b = 1 min read Ruby | Hash store() method Hash#store() is a Hash class method that returns an add-on value with the key given by the key-value argument. Syntax: Hash.store()Parameter: Hash values key valueReturn: add on value with the key given by the key-value argument. Example #1 : Ruby # Ruby code for Hash.store() method # declaring H 2 min read Ruby | Hash == value Hash#==() : ==() is a Hash class method which checks the equality of two Hash values. Syntax: Hash.==() Parameter: Hash values Return: true - if a == b otherwise return false Example #1: Ruby # Ruby code for Hash.==() method # declaring Hash value a = {a:100, b:200} # declaring Hash value b = {a:100 2 min read Like