From: Ryan Davis Date: 2010-02-11T07:11:44+09:00 Subject: Re: difference between [] and Array[] On Feb 10, 2010, at 13:10 , artbot wrote: > hi, > > all the time i thought [] would be a shortcut for the corresponding > class method of the class Array, but after > > def Array.[](*args) > puts "blah" > end > > i still get > > a= [1, 2, 3] > => [1, 2, 3] > > and on the other hand > > a= Array[1, 2, 3] # or a= Array.[](1, 2, 3) > blah > => nil > > so what is the exact cause of the difference? > > can I somehow redefine the 'global' [] no. [1, 2, 3] is an array literal and part of the syntax. It does not invoke a method. Array[...] is, as you point out in the comment, a method invocation to Array::[](*items).