Find maximum array element in Ruby Last Updated : 13 Sep, 2021 Summarize Comments Improve Suggest changes Share Like Article Like Report In this article, we will learn how to find maximum array element in Ruby. There are multiple ways to find maximum array element in Ruby. Let's understand each of them with the help of example. Example #1: ruby # max function on list arr =[1, 2, 3, 4, 5].max print arr print "\n" str1 = [1, 2, 3, 4, 5] puts str1.max print "\n" # max function on string str = ["GFG", "G4G", "Sudo", "Geeks"] print str.max Output: 5 5 Sudo Example #2: ruby # Function to find the max using max method def max(*arr) arr.max end print max(1, 2, 3, 4, 5) Output: 5 Example #3: A bit slower method ruby # Using enumerable#max val = ('1'..'6').to_a.max print val Output: 6 Comment More infoAdvertise with us Next Article Find minimum array element in Ruby S Shivam_k Follow Improve Article Tags : Ruby Ruby Array Similar Reads Find minimum array element in Ruby In this article, we will learn how to find minimum array element in Ruby. There are multiple ways to find minimum array element in Ruby. Let's understand each of them with the help of example. Example #1: ruby # min function on list arr =[1, 2, 3, 4, 5].min print arr print "\n" str1 = [1, 1 min read Remove array elements in Ruby In this article, we will learn how to remove elements from an array in Ruby. Method #1: Using Index Ruby # Ruby program to remove elements # in array # creating string using [] str = ["GFG", "G4G", "Sudo", "Geeks"] str.delete_at(0) print str Output: ["G4G", "S 1 min read Ruby | Matrix find_element() function The find_index is an inbuilt method in Ruby returns the index position of the given number. If the element is present more than once, the first occurrence is returned. If the element is not present, then nil is returned. Syntax: mat1.find_index(element)Parameters: The function needs an element which 1 min read Add array elements in Ruby In this article, we will learn how to add elements to an array in Ruby.Method #1: Using Index Ruby # Ruby program to add elements # in array # creating string using [] str = ["GFG", "G4G", "Sudo", "Geeks"] str[4] = "new_ele"; print str # in we skip t 1 min read Ruby | Matrix element() function The element() is an inbuilt method in Ruby returns the element present at the intersection of i-th row and j-th column. Syntax: mat1.element(i, j) Parameters: The function accepts two parameters i and j which signifies the row_number and column_number. Return Value: It returns the element at mat[i][ 1 min read Ruby | Array class find_index() operation Array#find_index() : find_index() is a Array class method which returns the index of the first array. If a block is given instead of an argument, returns the index of the first object for which the block returns true. Syntax: Array.find_index() Parameter: block - condition to follow Return: index va 1 min read Like