Trying to iterate over a array using ruby and it is miserably failing,
My Array
people = [{first_name: "Gary", job_title: "car enthusiast", salary: "14000" },
{first_name: "Claire", job_title: "developer", salary: "15000"},
{first_name: "Clem", job_title: "developer", salary: "12000"}]
How to iterate over the above hash to output only the salary value???
I tried using:
people.each do |i,j,k|
puts "#{i}"
end
The results are as below and is not what i was intending,
{:first_name=>"Gary", :job_title=>"car enthusiast", :salary=>"14000"}
{:first_name=>"Claire", :job_title=>"developer", :salary=>"15000"}
{:first_name=>"Clem", :job_title=>"developer", :salary=>"12000"}
Is there a way to iterate through this array and simply list out only the salary values and not the rest???
Thank you,
Aucun commentaire:
Enregistrer un commentaire