From: pp Date: 2011-02-24T17:44:52+09:00 Subject: Re: a, b = Array.new(2).map!{|x| data.dup} --_503a4112-875c-4407-9379-697143ca8267_ Content-Type: text/plain; charset="gb2312" Content-Transfer-Encoding: 8bit oops, this doesn't work.... sorry > Date: Thu, 24 Feb 2011 17:42:11 +0900 > From: tdihp@hotmail.com > Subject: Re: a, b = Array.new(2).map!{|x| data.dup} > To: ruby-talk@ruby-lang.org > > > [@scr, @png, @pdf, @svg, @ps].collect!{|x| @output.dup} > > > Date: Thu, 24 Feb 2011 06:46:15 +0900 > > From: mail@ssalewski.de > > Subject: a, b = Array.new(2).map!{|x| data.dup} > > To: ruby-talk@ruby-lang.org > > > > I think I can replace this code > > > > @scr = @output.dup > > @png = @output.dup > > @pdf = @output.dup > > @svg = @output.dup > > @ps = @output.dup > > > > with this equivalent: > > > > @scr, @png, @pdf, @svg, @ps = Array.new(5).map!{|x| @output.dup} > > > > Is there a nicer variant available? > > > > (Of course @scr, @png, @pdf, @svg, @ps = @output.dup will not work, I > > need 5 independent instances.) > > > > Thanks, > > > > Stefan Salewski > > > > > > > --_503a4112-875c-4407-9379-697143ca8267_--