There are plenty of answers that allow us to achieve this like so:
array = [a: 1, b: 2, c: 3]. But what I'm looking for is something more closer to c++ or java implementation.
In C++ we can define an array of pairs like so:
map <pair<int,int>,int> mp;
and perhaps use it for assigning values like:
mp[{x1,y1}] = 1;
Or to check if some element exist like so:
while(range(x,y) && !mp[{x,y}]) {
x += xx;
y += yy;
ans++;
}
Now the question is, how can we define our array of hashes similar to c++ where we have something like:
array = [{1,1}: 1, {2,2}: 2, {3,3}: 3]
a = [1,2,3]? Please edit to clarify.{1,1}is not a valid Ruby object. Do you mean the array[1,1]?