Ruby | Array size() operation Last Updated : 06 Dec, 2019 Summarize Comments Improve Suggest changes Share Like Article Like Report 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, 4, 1, 1, 88, 9] # declaring array c = [18, 22, 50, 6] # size method example puts "size() method form : #{a.size()}\n\n" puts "size() method form : #{b.size()}\n\n" puts "size() method form : #{c.size()}\n\n" Output : size() method form : 6 size() method form : 6 size() method form : 4 Example #2 : Ruby # Ruby code for size() method # declaring array a = ["abc", "nil", "dog"] # declaring array c = ["cat", nil] # declaring array b = ["cow", nil, "dog"] # size method example puts "size() method form : #{a.size()}\n\n" puts "size() method form : #{b.size()}\n\n" puts "size() method form : #{c.size()}\n\n" Output : size() method form : 3 size() method form : 3 size() method form : 2 Comment More infoAdvertise with us Next Article Ruby | Array count() operation M mayank5326 Follow Improve Article Tags : Ruby Ruby-Methods 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 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 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 rassoc() operation 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 1 min read Like