From: Dave Thomas Date: 2001-03-31T05:48:56+09:00 Subject: [ruby-talk:13364] Re: Ruby does not take space in array reference Tigger writes: > >|Is this the intended behavior? I like putting in lost of white space into > >|code that I write, and would like to reference the array as a [0] rather > >|than a[0]. > > > >Yes. It's intended. Ruby is very sensitive to existence of space(s). > > I guess my question is: Does it have to be this way? I can't speak for Matz, but one possible problem is the ambiguity: a [ 1 ] Is this a call to the [] method in 'a', or is it a call to a method called 'a' passing in as a parameter an array with one element? def a(param) "In a, param = #{param.inspect}" end a = Array.new a << 22 << 33 a[1] #=> 33 a [1] #=> "In a, param = [1]" Remember that other languages have rules about whitespace too. It's just that Ruby is different in that method names may look like operators. Regards Dave