It is possible to manage multiple values in order with one variable. The array is generated by enclosing it in square brackets .
fruits = ["apple","lemon","strawberry"] puts fruits # apple lemon strawberry Is output
Operators that perform various operations on arrays are called array operators. If you want to add additional elements to the already generated array, use <<
fruits = ["apple","lemon","strawberry"] fruits << "orange" puts fruits #The contents of the array["apple","lemon","strawberry","orange"]Next door apple lemon strawberry orange Is output
Extract using the number assigned to each element of the array called subscript. Subscripts start from 0 and increase in order.
You can get the element by specifying the subscript corresponding to the element you want to get. To get the array, enclose the array and the subscript of the element you want to get with square brackets .
fruits = ["apple","lemon","strawberry"] puts fruits #lemon is output that's all.