Kain Nobel
Member
Good day everybody!
I come today to ask what I'm hoping will be a quick question, for the Hash class. What I basically need to do is I'm writting an Equipment Optimization system, which automatically equips each piece of equipment based off the highest stat(s) requested (highest .atk and .str for instance), which I've got semi-covered, but then I realized that I need the information to be stored in the format of a Hash, but I don't know how to automatically generate a hash like I need. It needs to list the Equipments' IDs => Equipments' Stats, like so...
But I need a method similiar to the 'Array.push(object)' method or the 'Array << object' method, so I can do...
Is there a way to generate information into a Hash in a similiar fashion to this, or would I just be better off just using an Array in a similiar fashion and pretending its a hash?
I come today to ask what I'm hoping will be a quick question, for the Hash class. What I basically need to do is I'm writting an Equipment Optimization system, which automatically equips each piece of equipment based off the highest stat(s) requested (highest .atk and .str for instance), which I've got semi-covered, but then I realized that I need the information to be stored in the format of a Hash, but I don't know how to automatically generate a hash like I need. It needs to list the Equipments' IDs => Equipments' Stats, like so...
Code:
hash = {1 => 112, 2 => 140, 3 => 175, 4 => 218}
But I need a method similiar to the 'Array.push(object)' method or the 'Array << object' method, so I can do...
Code:
hash = Hash.new
$data_weapons.each do |w|
hash << {w.id => w.atk}
end
Is there a way to generate information into a Hash in a similiar fashion to this, or would I just be better off just using an Array in a similiar fashion and pretending its a hash?