I
Igor Nn
Hello -
I have a hash table of several items.
What I would like to do is loop through the hash and do a different
action based on each unique key.
my_hash_table.each_pair do |k, v|
# Call a method if a hash key == "a"
# Call a different method if hash key == "b"
# Call a third method if a hash key == "c"
end
I have been trying to implement this with "if" and "case", but the loop
stops once the first argument is satisfied.
Can you please point into the right direction of how to go about solving
this problem.
Thank you!
I have a hash table of several items.
What I would like to do is loop through the hash and do a different
action based on each unique key.
my_hash_table.each_pair do |k, v|
# Call a method if a hash key == "a"
# Call a different method if hash key == "b"
# Call a third method if a hash key == "c"
end
I have been trying to implement this with "if" and "case", but the loop
stops once the first argument is satisfied.
Can you please point into the right direction of how to go about solving
this problem.
Thank you!