Ruby | Array rindex() function Last Updated : 06 Dec, 2019 Comments Improve Suggest changes Like Article Like Report Array#rindex() : rindex() is a Array class method which returns the index of the last object in the array. Syntax: Array.rindex() Parameter: Array Return: the index of the last object in the array. if not present then nil Example #1 : Ruby # Ruby code for rindex() method # declaring array a = [18, 22, 33, nil, 5, 6] # declaring array b = [1, 4, 1, 1, 88, 9] # declaring array c = [18, 22, 50, 6] # rindex method example puts "rindex() method form : #{a.rindex(22)}\n\n" puts "rindex() method form : #{b.rindex(1)}\n\n" puts "rindex() method form : #{c.rindex(18)}\n\n" Output : rindex() method form : 1 rindex() method form : 3 rindex() method form : 0 Example #2 : Ruby # Ruby code for rindex() method # declaring array a = ["abc", "nil", "dog"] # declaring array c = ["cat", nil] # declaring array b = ["cow", nil, "dog"] # rindex method example puts "rindex() method form : #{a.rindex("abc")}\n\n" puts "rindex() method form : #{b.rindex("cat")}\n\n" puts "rindex() method form : #{c.rindex("cat")}\n\n" Output : rindex() method form : 0 rindex() method form : rindex() method form : 0 Comment More infoAdvertise with us Next Article Ruby | Array rindex() function M mayank5326 Follow Improve Article Tags : Ruby Ruby-Methods Ruby Array-class Similar Reads Ruby | Array one?() function Array#one?() : one?() is a Array class method which checks whether the array is having only one array element. Syntax: Array.one?() Parameter: Array Return: true - if array has only one element otherwise return false. Example #1 :Â Ruby # Ruby code for one?() method # declaring array a = [18, 22, 33 1 min read Ruby | Array min() function Array#min() : min() is a Array class method which returns the minimum value in this array. Syntax: Array.min() Parameter: Array Return: the minimum value in this array. Example #1 : Ruby # Ruby code for min() method # declaring array a = %w[for geeks] # min method example puts "min() method for 1 min read Ruby | Array class index() function index() is an Array class method which returns the index of the first object in the array. Syntax: Array.index() Parameter: Array obj - object to search for Return: Index value of the first array Example #1 : Ruby # Ruby code for index() method # declaring array a = [18, 22, 33, nil, 5, 6] # declari 1 min read Ruby | Array none?() function Array#none?() : none?() is a Array class method which checks whether the array is empty or not. Syntax: Array.none?() Parameter: Array Return: true - if array has no elements otherwise return false Example #1 : Ruby # Ruby code for none?() method # declaring array a = [18, 22, 33, nil, 5, 6] # decla 1 min read Ruby | Array max() function Array#max() : max() is a Array class method which returns the maximum value in this array. Syntax: Array.max() Parameter: Array Return: the maximum value in this array. Example #1 : Ruby # Ruby code for max() method # declaring array a = %w[for geeks] # max method example puts "max() method for 1 min read Like