Suppose that i have 2 objects, where each one has a particular slot numbered from 1-5 (unique). Say that object1 has slot = 3 and object2 slot = 5.
What is an effective way to create a hash like :
{ 1 => nil, 2 => nil, 3 => object1, 4 => nil, 5 => object2}
I suppose map could be used, but what’s the best way ?
EDIT : 5 is just an example, please pretend that you do not know the number of slots.
Also: