Array hashes in Ruby?
Posted: Wed Sep 21, 2016 12:04 pm
Hi guys,
Here is a little ruby challenge I'm trying to deal with:
I would like to use hashes to define string values just like the "if then" primitive does, but unlike with the standard ruby hashes code where the whole defining process done inside the ruby primitive, I would like to define it externally, by feeding the code with 2 random string arrays. The first array would be used as a "variable to be compared" list and the second would be used as a "condition" list.
So, the ruby code should have 3 inputs and one output. The inputs would be:
1) "user" input
2) "variable to be compared" input
3) "condition" input
The output would be just the "final result".
Each index in the first array is actually equivalent to the same index int second array, so for instance if the arrays are:
a
b
c
1
2
3
it means that a=1,b=2,c=3. Therefore, if the user's string input is "cab" the array would 3,1,2 so the "final result" would be:
3
1
2
Also attached a small diagram schematic that describes the wanted structure.
Thanks
Here is a little ruby challenge I'm trying to deal with:
I would like to use hashes to define string values just like the "if then" primitive does, but unlike with the standard ruby hashes code where the whole defining process done inside the ruby primitive, I would like to define it externally, by feeding the code with 2 random string arrays. The first array would be used as a "variable to be compared" list and the second would be used as a "condition" list.
So, the ruby code should have 3 inputs and one output. The inputs would be:
1) "user" input
2) "variable to be compared" input
3) "condition" input
The output would be just the "final result".
Each index in the first array is actually equivalent to the same index int second array, so for instance if the arrays are:
a
b
c
1
2
3
it means that a=1,b=2,c=3. Therefore, if the user's string input is "cab" the array would 3,1,2 so the "final result" would be:
3
1
2
Also attached a small diagram schematic that describes the wanted structure.
Thanks