Ruby | Array at() operation Last Updated : 08 Jan, 2020 Comments Improve Suggest changes Like Article Like Report 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 # declaring array a = [18, 22, 33, 4, 5, 6] # declaring array b = [5, 4, 22, 1, 88, 9] # declaring array c = [18, 22, 33, 40, 50, 16] # finding the array element at # given index puts "element : #{a.at(4)}\n\n" puts "element : #{a.at(-1)}\n\n" puts "element : #{b.at(-2)}\n\n" puts "element : #{c.at(-4)}\n\n" Output : element : 5 element : 6 element : 88 element : 33 Code #2 : Example for at() method Ruby # Ruby code for at() method # declaring array a = ["abc", "xyz", "dog"] # declaring array b = ["cow", "cat", "dog"] # declaring array c = ["cat", "1", "dog"] # finding the array element at # given index puts "element : #{a.at(4)}\n\n" puts "element : #{a.at(-1)}\n\n" puts "element : #{b.at(-2)}\n\n" puts "element : #{c.at(2)}\n\n" Output : element : element : dog element : cat element : dog Comment More infoAdvertise with us Next Article Ruby | Array at() operation M mayank5326 Follow Improve Article Tags : Ruby Ruby-Methods Ruby Collections Ruby Array-class Similar Reads 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 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 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. Syntax: Array.compact() Parameter: Array to remove the 'nil' value from. Return: removes all the nil values from the array. Code #1 : Example for compact 2 min read Ruby | Array count() operation Array#count() : count() is a Array class method which returns the number of elements in the array. It can also find the total number of a particular element in the array. Syntax: Array.count() Parameter: obj - specific element to found Return: removes all the nil values from the array. Code #1 : Exa 2 min read Ruby | Array dig() operation 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() metho 1 min read Like