Hash Parsing with Ruby -


i have array of hash shown below:

@line_statuses = [   {:name=>"1", :status=>"online"},   {:name=>"2", :status=>"online"} ] 

i'd parse each hash inside of @line_statuses array can print out name , status shown below.

1: online 2: online 

how go doing this?

technically @line_statuses variable array, have array of hashes. in ruby, iterate on array use .each method. then, in each iteration, can access values of hash using defined keys:

@line_statuses.each |hash|   puts hash[:name]   puts hash[:status] end 

Comments

Popular posts from this blog

java - Andrioid studio start fail: Fatal error initializing 'null' -

android - Gradle sync Error:Configuration with name 'default' not found -

StringGrid issue in Delphi XE8 firemonkey mobile app -