Ruby | Array rassoc() operation Last Updated : 21 Aug, 2021 Summarize Comments Improve Suggest changes Share Like Article Like Report Array#rassoc() : rassoc() is an Array class method which searches an element through the array. Syntax: Array.rassoc() Parameter: - Arrays for finding elements. - elements to detect Return: Array after adding the elements at the end. Code #1 : Example for rassoc() method Ruby # Ruby code for rassoc() 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] ar = [a, b, c] # searching for an element puts "check : #{ar.rassoc(4)}\n\n" puts "check : #{ar.rassoc(22)}\n\n" Output : check : [5, 4, 22, 1, 88, 9] check : [18, 22, 33, 4, 5, 6] Code #2 : Example for rassoc() method Ruby # Ruby code for rassoc() method # declaring array a = ["abc", "xyz", "dog"] # declaring array b = ["cow", "cat", "dog"] # declaring array c = ["cat", "1", "dog"] ar = [a, b, c] # searching for an element puts "check : #{ar.rassoc("xyz")}\n\n" puts "check : #{ar.rassoc("1")}\n\n" Output : check : ["abc", "xyz", "dog"] check : ["cat", "1", "dog"] Comment More infoAdvertise with us Next Article Ruby | Array size() 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 any?() operation any?() is an Array class method which checks for the presence of a pattern and passes each element of the collection to the given block. Syntax: Array.any?() Parameter: array for testing Return: true if the block ever returns a value other than false or nil otherwise return false. Example #1 :Â Ruby 1 min read Ruby | Array size() operation Array#size() : size() is a Array class method which returns the length of elements in the array. Syntax: Array.size() Parameter: Array Return: the length of elements in the array. Example #1 : Ruby # Ruby code for size() method # declaring array a = [18, 22, 33, nil, 5, 6] # declaring array b = [1, 1 min read Ruby | Array cycle() operation Array#cycle() : cycle() is a Array class method which returns the array by calling the given block each time for every element in the array 'n' no. of times and if 'nil' is given, then it will call it for forever. Syntax: Array.cycle() Parameter: block - condition n - number of times to call the blo 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 Like