Checking to see if all values in an array are equal
[Rewritten]

You want to avoid inject, as uniq.size is O(n) and clearer. Monkey patching array makes the code clearer and is idiomatic Ruby. Methods that return a boolean should end in ?. Method names should be snake_case. Here you go:

class Array
  # Check to see if all values in the first dimension are equal
  def constant_1d?
    uniq.size == 1
  end

  # Check to see if all values in the second dimension are equal
  def constant_2dy?
    all?(&amp;:constant_1d?)
  end

  # Check to see if all values in the third dimension are equal
  def constant_3dz?
    all?(&amp;:constant_2dy?)
  end
end