From: Brian Candler Date: 2003-07-10T00:32:58+09:00 Subject: Re: Code Snippet: Array.shuffle On Thu, Jul 10, 2003 at 12:16:59AM +0900, Mauricio Fern�ndez wrote: > 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] Ah, I see: foo[bar] => foo.[] (bar) foo [bar] => foo( [bar] ) Yuk. This exists in 1.6.8. I guess it mirrors Matz's change introduced for 1.8: foo(a+b).c => ( foo(a+b) ).c foo (a+b).c => foo( (a+b).c ) As for the semicolon, it seems that irb does not play nicely with unusual symbols: $ irb irb(main):001:0> :ok => :ok irb(main):002:0> :[] irb(main):003:0* puts "oops" oops => nil irb(main):004:0> Cheers, Brian.