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 code for Hash.==() 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} # COMPARING TWO Hash VALUES puts "Hash a == b : #{a==b}\n\n" # b puts "Hash b == c : #{b==c}\n\n" # c puts "Hash a == c : #{c==a}\n\n" |
chevron_right
filter_none
Output :
Hash a == b : false Hash b == c : false Hash a == c : false
Example #2:
# Ruby code for Hash.==() 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} # COMPARING TWO Hash VALUES puts "Hash a == b : #{a==b}\n\n" # b puts "Hash b == c : #{b==c}\n\n" # c puts "Hash a == c : #{c==a}\n\n" |
chevron_right
filter_none
Output :
Hash a == b : false Hash b == c : false Hash a == c : false
Recommended Posts:
- Ruby | Hash dig() function
- Ruby | Hash > method
- Ruby | Hash < method
- Ruby | Hash value? method
- Ruby | Hash each() function
- Ruby | Hash key() function
- Ruby | Hash eql? function
- Ruby | Hash key?() function
- Ruby | Hash any?() function
- Ruby | Hash Class
- Ruby | Hash to_s() function
- Ruby | Hash has_key?() function
- Ruby | Hash shift() method
- Ruby | Hash rehash function
- Ruby | Hash keys() function
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.


