Ruby | Hash reject! method Last Updated : 07 Jan, 2020 Summarize Comments Improve Suggest changes Share Like Article Like Report Hash#reject!() is a Hash class method which checks whether any changes are made in the hash array or not Syntax: Hash.reject!() Parameter: Hash values Return: true - if changes are made otherwise return false Example #1 : Ruby # Ruby code for Hash.reject!() 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} # reject! Value puts "Hash a reject! form : #{a.reject! {|key, value| key < "b"}}\n\n" Output : Hash a reject! form : {"b"=>200} Example #2 : Ruby # Ruby code for Hash.reject!() method # declaring Hash value b = {"a" => 100} # declaring Hash value c = {"a" => 100, "c" => 300, "b" => 200} # reject! Value puts "Hash b reject! form : #{b.reject!{|key, value| value < 200}}\n\n" puts "Hash c reject! form : #{c.reject!{|key, value| key < "b"}}\n\n" Output : Hash b reject! form : {} Hash c reject! form : {"c"=>300, "b"=>200} Comment More infoAdvertise with us Next Article Ruby | Hash replace() method K Kirti_Mangal Follow Improve Article Tags : Ruby Ruby-Methods Ruby Hash-class Similar Reads Ruby | Hash reject method Hash#reject() is a Hash class method which returns a new hash which consists of entries for which the block returns false. Syntax: Hash.reject() Parameter: Hash values Return: new hash which consists of entries for which the block returns false. enumerator - If no block is given Example #1 : Ruby # 2 min read Ruby | Hash replace() method Hash#replace() : replace() is a Hash class method which replaces the content of one hash with other. Syntax: Hash.replace() Parameter: Hash values Return: replaces the content of one hash with other. Example #1 : Ruby # Ruby code for Hash.replace() method # declaring Hash value a = {a:100, b:200} # 2 min read Ruby | Hash to_proc method Hash#to_proc() : to_proc() is a Hash class method which returns a Proc which maps 'keys' value to 'value' value. Syntax: Hash.to_proc() Parameter: Hash values Return: Proc which maps 'keys' value to 'value' value. Example #1 : Ruby # Ruby code for Hash.to_proc() method # declaring Hash value a = {a: 2 min read Ruby | Hash < method Hash#<() is a Hash class method which compares 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, c:300, b:2 1 min read Ruby | Hash > method Hash#>() is a Hash class method compares 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, c:300, b:200} # 2 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 Like