baris dan kolom zip ruby

columns = [ "Name", "city", "employed"]
 
rows = [ 
  [ "Matt",   "Seattle",    true ], 
  [ "Amy",  "Chicago", true], 
  [ "Nice", "Lahore",     false ]
]

rows.map{|r| Hash[ columns.zip(r) ] }
# [
#	{"Name"=>"Matt", "city"=>"Seattle", "employed"=>true}, 
#	{"Name"=>"Amy", "city"=>"Chicago", "employed"=>true}, 
#	{"Name"=>"Nice", "city"=>"Lahore", "employed"=>false}
# ]
patrick204nqh