Arrays in Ruby are ordered collections of any object. They are one of the most commonly used data structures in Ruby and provide a way to store multiple items in a single variable. Arrays can contain any type of data, including numbers, strings, and other arrays.
numbers = [1, 2, 3]
alphabet = ["a", "b", "c"]
mixed_array = [1, 2, "abc", "xyz", 23.0]
all_arrays = [numbers, alphabet, 1, 2, nil]
[1, 2, 3].size
[1, 2, 3].length
[1, 2, 3].count
[1, 2, 3, nil].compact
[1, 2, 3, 3, 2].uniq
[1, 2, 3].clear
[1, 2, 3].reverse
[1, 2, 3].include?(2)
[1, 2, 3].include?(0)
[1, 2, 3].join(", ")
[1, 2, 3].join("-")
[[1, 22, 333], "a", "b"].flatten