Learnerslesson
   JAVA   
  SPRING  
  SPRINGBOOT  
 HIBERNATE 
  HADOOP  
   HIVE   
   ALGORITHMS   
   PYTHON   
   GO   
   KOTLIN   
   C#   
   RUBY   
   C++   




RUBY - HASH METHODS


Methods used in Hash


We have described almost all the Methods above. Below is the list of methods used in Hash.





Method Description
assoc(obj) Used to compare the parameter 'obj' in the Hash
compare_by_identity() Used to compare the Keys in the Hash by Identity
compare_by_identity? Used to compare the Keys in the Hash by Identity.
default(key=nil) Used to provide the default value if the key is not present in Hash
clear() Used to remove all the elements from the Hash
default = obj Used to set the default value for Hash
delete(key) Used to delete the Key Value pair using its key
empty? Used to return true if the Hash is empty
fetch(key[, default]) Used to return a value from hash for that key. If default value is provided, it's returned
hash.fetch(key) { | key | block } Used to return a value from hash for that key. If default value is provided, it's returned
flatten Used to return an one-dimensional array from the Hash
has_key?(key) Used to return true true if the key is present in the hash
has_value?(value) Used to return true true if the value is present in the hash
include?(key) Used to return true if given key is present in hash.
to_s Used to convert the Hash to a String
inspect Used to convert the Hash to a String