-
-
Save jrasanen/0681fcfd03c7329e7d7fd7b03133233e 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
numbers = [50, 43, 73, 22] | |
data = numbers.map.with_index do |x, i| | |
return { "a": i, "b": x } | |
end | |
puts(data) // => {"a"=>0, "b"=>50} |
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
numbers = [50, 43, 73, 22] | |
data = numbers.map.with_index{ |x, i| | |
{ "a" => i, "b" => x } | |
} | |
puts(data) // => [{"a"=>0, "b"=>50}, {"a"=>1, "b"=>43}, {"a"=>2, "b"=>73}, {"a"=>3, "b"=>22}] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment