From: gwtmp01@... Date: 2005-10-28T23:18:53+09:00 Subject: Re: Argument Passing Syntax On Oct 28, 2005, at 5:24 AM, Sean O'Halpin wrote: > o.[](1,2,3) { |x| p x } # this is what you have to do in 1.8 > o[1,2,3] { |x| p x } # this causes syntax error in 1.8 but works > in 1.9 Here is a related thought. Right now you can't have arguments to an "assignment method": class A def attribute1=(*args, &block) @attr1 = value end end a = A.new a.attribute1 = 4 # ok a.attribute1(4) = 5 # syntax error a.attribute1=(4, 5) # syntax error a.send(:attribute1=, 4,5) # ok Why not allow the middle two cases? I think this would be helpful when a class is wrapping one or more "containers" (Array, Hash, Set,...) and you don't want to expose the entire interface of the container outside of the class. You can do this reasonably well with :[] and :[]= for a single container but you can't have methods such as :container2[] and :container2[]= because of the parsing problems: container2[index] = val # is this self.container2.[] (index,val) or # is this self.container2[](index,val) But if you allowed for arguments to :container= then you could do something like: container2(index) # lookup contents of @container2[index] container2(index) = value # modify contents of @container2[index] Right now if you want to package multiple containers in a class you need to create set/get methods for each container that map to :[]/[]= for the container or insert some sort of proxy class to avoid exposing the entire container. Is there a parsing hurdle to overcome or is there some conceptual reason for prohibiting additional arguments to assignment methods?