From: Brian Candler Date: 2011-02-24T06:58:14+09:00 Subject: Re: a, b = Array.new(2).map!{|x| data.dup} Stefan Salewski wrote in post #983432: > 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? # here's one @scr, @png, @pdf, @svg, @ps = Array.new(5) { @output.dup } # here's another, not for <=1.8.6 @scr, @png, @pdf, @svg, @ps = 5.times.map { @output.dup } But I think the original 5 lines is clearer :-) -- Posted via http://www.ruby-forum.com/.