Ruby Hash Key Reference
问题 Hello I have a custom Hash that needs to be returned in an API. But currently I'm struggling to find a good way to do so. The following example will describe the problem. Lets say we have the following code: data = {name: "Jon", value: "13"} results = [] [1, 2, 3, 4, 5].each do |i| data[:id] = i results << data end # output # results = [{name: "Jon", value: "13", id: 5}, {name: "Jon", value: "13", id: 5}, {name: "Jon", value: "13", id: 5}, {name: "Jon", value: "13", id: 5}, {name: "Jon",