Answers for "iterate through an array of hashes ruby"

1

iterating over hash, ruby

# iterating_over_hashes.rb

person = {name: 'bob', height: '6 ft', weight: '160 lbs', hair: 'brown'}

person.each do |key, value|
  puts "Bob's #{key} is #{value}"
end


#Returns
#Bob's name is bob
#Bob's height is 6 ft
#Bob's weight is 160 lbs
#Bob's hair is brown
Posted by: Guest on December-31-2020
1

ruby loop through array

numbers = [0, 1, 2, 3]
for element in numbers do
  puts element
end
Posted by: Guest on October-04-2020

Code answers related to "iterate through an array of hashes ruby"

Browse Popular Code Answers by Language