To avoid ambiguity. Consider the following:
def foo(a, b = 1)
This can be interpreted as [(foo 1), 2] or as [(foo 1, 2)] .
There are two references to calling methods (although they are not directly related to the array literal):
Note that parentheses are optional ... Except where there is a difference between use and the absence of parentheses
In many cases, parentheses are not needed when sending a message ... However, parentheses are needed to avoid ambiguity.
source share