From: Charles Oliver Nutter Date: 2012-09-20T10:26:48+09:00 Subject: [ruby-core:47609] Re: [ruby-trunk - Feature #6668] Multiple assignment should not return an Array object On Wed, Sep 19, 2012 at 3:38 AM, SASADA Koichi wrote: > FYI, from 1.9 the Array for RHS is not generated if it is not needed. > > # not generated > a, b = c, d > a, b, c = d, e system ~/projects/jruby $ ruby-1.9.3 -e "def foo(c, d); a, b = c, d; end; p foo 1, 2" [1, 2] system ~/projects/jruby $ ruby-1.9.3 -e "def foo(d, e); a, b, c = d, e; end; p foo 1, 2" [1, 2] Perhaps by not needed you mean "not used in an expression"? > # generated > a = b, c > a = b, c, d > > I remain the spec because of compatibility. > #=> go to matz issue. > > As you say the case which need to generate an array are not major case, > it is not performance problem in my opinion. I disagree. For example, the following case would make instance variable initialization much cheaper if the array did not have to be constructed: def initialize(a, b, c) @a, @b, @c = a, b, c end As above, since this line is the return value from the method, an array would be created that nobody ever uses. There are many similar cases where multiple assignment just happens to be the last line of a method but nobody cares about the Array result...so it is wasted effort to create it. - Charlie