Question: I have an array as follows:

```
 my_array =   [
      [value_1, value_2, value_3, value_4],
      [value_n1, value_n2, value_n3, value_n4],
      [value_x1, value_x2, value_x3, value_x4],
      [value_y1, value_y2, value_y3, value_y4],
      [value_z1, value_z2, value_z3, value_z4]
    ]

```

I find the array that has some value and then affect their values. For example:

```
some_value = 'xyz'
if my_array.map(&:first).include? some_value # I always compare 'some_value' with the first element of each array

  # find the array
  my_array.select{ |s| s.include? some_value }

  # affect the values with position [1], [2], [3]
  # ...

end

```

Is there a simple way to extract the array and affect their values​​?

EXAMPLE
-------

I have an array:

```
array = [ ['abc', 4, 5], ['xyz', 2, 10], ['ubf', 40, 9] ]

```

And a value: `x = 'abc'`

When my variable 'x' begins to compare with the arrays that I have and find the array that contain this value. Then, should add 1 to the other other values​​. So, my expected result is:

```
array = [ ['abc', **5**, **6**], ['xyz', 2, 10], ['ubf', 40, 9] ]

```

Other value: `x = 'ubf'`

Result: `array = [ ['abc', 5, 6], ['xyz', 2, 10], ['ubf', **41**, **10**] ]`

Answer: 
Finding sub-array by its first element is a job of [`Array#assoc`](http://www.ruby-doc.org/core-2.1.2/Array.html#method-i-assoc) method.
Increasing value of following elements is a straightforward task. Possible implementation:

```
array = [ ['abc', 4, 5], ['xyz', 2, 10], ['ubf', 40, 9] ]
x = 'abc'

marr = array.assoc(x)
marr[1..-1] = marr.drop(1).map {|v| v+1} if marr
p array
# [["abc", 5, 6], ["xyz", 2, 10], ["ubf", 40, 9]]

```
Maybe something along these lines:

```
my_array.map{|a| a.include?(some_value) ? transform(a) : a }

def transform array
  #return your modified array
end

```

If you fed that `[[1,2],[2,3],[3,4]]` and you had `some_value` set to 3, you could use

```
def transform array do
    array.map{|k| k + 1}
  end

```

to get `[[1,2], [3,4], [4,5]]`