Skip to content

Instantly share code, notes, and snippets.

/ruby.rb Secret

Created November 22, 2016 18:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/b3ac5ba82a709c98474c604139710550 to your computer and use it in GitHub Desktop.
Save anonymous/b3ac5ba82a709c98474c604139710550 to your computer and use it in GitHub Desktop.
arr = [
{"id"=>10569, "home_team_record"=>"1-2", "away_team_record"=>"2-2", "home_team_score"=>47, "away_team_score"=>40, "progress"=>"14:21 - 2nd", "state"=>"in"},
{"id"=>8987, "home_team_record"=>"1-3", "away_team_record"=>"0-0", "home_team_score"=>87, "away_team_score"=>49, "progress"=>"6:43 - 2nd", "state"=>"in"}
]
# This is a summarized array, which is much larger.
# Instead of iterating every time I want to select a game, e.g. arr.find{|game| game['id'] == 8987}
# I want to rearrange the structure so I can just do something like arr['id'] == 8987 ?
# If so, how do I rearrange the structure to look like that?
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment