Today I Learned

Creating array without parentheses

One of the unique features in ruby is that you don’t need to use parentheses(most of the time). For example, you can skip them when you are defining or invoking a method.

What I didn’t know was that you don’t need brackets while creating a new array

pry(main)> new_array = 1, 2, 3 # => [1, 2, 3]

More examples:

pry(main)> new_array = 1, second = 2, third = 3 # => new_array = [1, 2, 3]; second = 2; third = 3
pry(main)> new_array = first = 1, second = 2, third = 3 # => new_array = [1, 2, 3]; first = 1; second = 2; third = 3