Ruby Language Arrays Creating an Array with the literal constructor [ ]

Help us to keep this website almost Ad Free! It takes only 10 seconds of your time:
> Step 1: Go view our video on YouTube: EF Core Bulk Insert
> Step 2: And Like the video. BONUS: You can also share it!

Example

Arrays can be created by enclosing a list of elements in square brackets ([ and ]). Array elements in this notation are separated with commas:

array = [1, 2, 3, 4]

Arrays can contain any kind of objects in any combination with no restrictions on type:

array = [1, 'b', nil, [3, 4]]


Got any Ruby Language Question?