From: Brian Candler Date: 2003-07-09T22:02:40+09:00 Subject: Re: Code Snippet: Array.shuffle On Wed, Jul 09, 2003 at 09:45:33PM +0900, Mauricio Fern�ndez wrote: > > > I got the error from -- a = array[1,2,3,4,5] > > > IRB will give a consistent error. > > > > Certainly. Ruby is case-sensitive. You need to call method [] of 'Array', > > not 'array' > > It's not Array.[], but Kernel#Array. You sure? This is Kernel#Array: Array(5) #>> [5] Array(5,6) #>> ArgumentError: wrong # of arguments(2 for 1) I believe that foo[bar] is a shortcut for foo.send(:[], bar) And therefore Array[1,2,3,4,5] is Array.send(:[], 1, 2, 3, 4, 5) #=> [1, 2, 3, 4, 5] or equivalently Array.[] (1,2,3,4,5) #=> [1, 2, 3, 4, 5] i.e. this is a class (singleton) method of Array Regards, Brian.