Skip to content

Instantly share code, notes, and snippets.

@sirchuck
Created September 25, 2017 19:20
Show Gist options
  • Save sirchuck/3ad1f276a177fa337201601fd55b3e1b to your computer and use it in GitHub Desktop.
Save sirchuck/3ad1f276a177fa337201601fd55b3e1b to your computer and use it in GitHub Desktop.
my_array = []
my_object = {
:one => "0",
:two => "0",
:three => "0",
}
other_array = ["1","2","3"]
other_array.each do |id|
my_object[:one] = id
my_array << my_object
end
# my_array[:one] will equal 3 for each array element.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment