On Wed, Jul 09, 2003 at 10:02:40PM +0900, Brian Candler wrote:
> On Wed, Jul 09, 2003 at 09:45:33PM +0900, Mauricio FernŠŌdez 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:

Shouldn't have asserted this so strongly as it turns out... I was wrong :-P  

Anyway, this is yet another case of significant spaces in Ruby:

>> class << Array
>>   alias_method :_old_, :[];
?>   def [](*a)
>>     puts "Array.[]"
>>     _old_(*a)
>>   end
>> end
=> nil
>> Array[1,2,3]
Array.[]
=> [1, 2, 3]
>> Array [1,2,3]
=> [1, 2, 3]


BTW, irb needs the ';' at the end of the second line:
>> class << Array
>>   alias_method :_old_, :[]
?>   def [](*a)
>>     puts "Array.[]"
>>     _old_(*a)
>>   end
SyntaxError: compile error
(irb):6: syntax error
        from (irb):6

bug?

-- 
 _           _                             
| |__   __ _| |_ ___ _ __ ___   __ _ _ __  
| '_ \ / _` | __/ __| '_ ` _ \ / _` | '_ \ 
| |_) | (_| | |_\__ \ | | | | | (_| | | | |
|_.__/ \__,_|\__|___/_| |_| |_|\__,_|_| |_|
	Running Debian GNU/Linux Sid (unstable)
batsman dot geo at yahoo dot com

'Ooohh.. "FreeBSD is faster over loopback, when compared to Linux
over the wire". Film at 11.'
	-- Linus Torvalds