From: Robert Klemme Date: 2007-06-28T18:50:02+09:00 Subject: Re: Is there a nifty ruby hack for this set of commands? On 28.06.2007 07:35, Phrogz wrote: > On Jun 27, 7:33 pm, Frank Church wrote: >> f = File.new(configfile, File::CREAT|File::WRONLY, 0700) >> header_commands.each {|x| f.puts x } >> mysql_commands.each {|x| f.puts x } >> dir_commands.each {|x| f.puts x } >> scp_commands.each {|x| f.puts x } > > File.new( configfile, File::CREAT|File::WRONLY, 0700){ |f| > f.puts [ header_commands, mysql_commands, dir_commands, > scp_commands ].flatten > } > > (Since puts will already join the array with \n) I believe there is an even simpler solution: File.open configfile, File::CREAT|File::WRONLY, 0700 do |f| f.puts header_commands, mysql_commands, dir_commands, scp_commands end :-) Kind regards robert