Created
May 17, 2016 00:00
-
-
Save dmerrick/f07ed68d93076aa131d8848d4b90362c to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env ruby | |
| input = { | |
| foo: [ 1, 2], | |
| bar: [ 3, 4] | |
| } | |
| num_args = input.values.first.size | |
| output = [] | |
| num_args.times do |index| | |
| new_hash = {} | |
| input.each do |key, value| | |
| new_hash[key] = value[index] | |
| end | |
| output << new_hash | |
| end | |
| puts output.inspect | |
| #=> [{:foo=>1, :bar=>3}, {:foo=>2, :bar=>4}] | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment