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]]

```
If you have an array but want it to behave in a special way, you may want to think about creating a class.

```
class EGC < Array
  def increment(val)
    self.map do |sub|
      if sub.first == val
        [val, sub[1..-1].map(&:next)].flatten
      else
        sub
      end
    end
  end
end

```

Then you can do this:

```
e = EGC.new([["foo", 1, 2], ["bar", 3, 4]])
#=> [["foo", 1, 2], ["bar", 3, 4]]

e.increment("foo")
#=> [["foo", 2, 3], ["bar", 3, 4]]

```

Of course, you should change the names to better reflect your problem domain.

That being said, it seems that you would be better off starting with a Hash instead of a 2D Array.