Ruby | Array dig() operation Last Updated : 08 Jan, 2020 Comments Improve Suggest changes Like Article Like Report Array#dig() : dig() is a Array class method which extracts the specific element out of the high dimension sequences. Syntax: Array.dig() Parameter: element position. Return: element from a specific location in sequence, returning nil if any intermediate step is nil. Code #1 : Example for dig() method Ruby # Ruby code for dig() method # declaring array a = [18, 22, 33, 23, 5, 6] # declaring array b = [[1, 4], [ 1, 1, 88, 9]] # dig puts "dig : #{a.dig(1)}\n\n" # dig puts "dig : #{b.dig(0, 1)}\n\n" # dig puts "dig : #{b.dig(1, 2)}\n\n" Output : dig : 22 dig : 4 dig : 88 Code #2 : Example for dig() method Ruby # Ruby code for dig() method # declaring array a = [["abc"], ["geeks", "dog"], ["1", "2"]] # declaring array b = [["cow"], ["1", "dog"]] # dig puts "dig : #{a.dig(2, 1)}\n\n" # dig puts "dig : #{a.dig(1, 1)}\n\n" # dig puts "dig : #{b.dig(1, 0)}\n\n" Output : dig : 2 dig : dog dig : 1 Comment More infoAdvertise with us Next Article Ruby | Array collect() operation M mayank5326 Follow Improve Article Tags : Ruby Ruby-Methods Ruby Collections Ruby Array-class Similar Reads Ruby | Array at() operation Array#at() : at() is an Array class method which returns the element at the specific argumented index value. Syntax: Array.at() Parameter: - Arrays to search elements. - index to search Return: Array element at a specific index value Code #1 : Example for at() method Ruby # Ruby code for at() method 1 min read Ruby | Array map!() operation Array#map!() : map!() is a Array class method which returns a new array containing the values returned by the block. Syntax: Array.map!() Parameter: Array Return: a new array containing the values returned by the block. Example #1 : Ruby # Ruby code for map!() method # declaring array a = [18, 22, 3 2 min read Ruby | Array map!() operation Array#map!() : map!() is a Array class method which returns a new array containing the values returned by the block. Syntax: Array.map!() Parameter: Array Return: a new array containing the values returned by the block. Example #1 : Ruby # Ruby code for map!() method # declaring array a = [18, 22, 3 2 min read Ruby | Array delete() operation Array#delete() : delete() is a Array class method which returns the array after deleting the mentioned elements. It can also delete a particular element in the array. Syntax: Array.delete() Parameter: obj - specific element to delete Return: last deleted values from the array. Code #1 : Example for 2 min read Ruby | Array collect() operation Array#collect() : collect() is an Array class method which invokes the argument block once for each element of the array. A new array is returned which has the value returned by the block. Syntax: Array.collect() Parameter: Arrays in which we want elements to be invoked Return: array with all the en 1 min read Ruby | Array compact!() operation Array#compact! () : compact! () is a Array class method which returns the array after removing all the 'nil' value elements (if any) from the array. If there are no nil values in the array it returns back the nil value. Syntax: Array.compact!() Parameter: Array to remove the 'nil' value from. Return 2 min read Like