From: Stefan Rusterholz Date: 2007-06-30T20:38:31+09:00 Subject: Re: Is there a nifty ruby hack for this set of commands? Frank Church wrote: > > I have this sequence of commands to write a list of values to a file > > 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 } > > Is there a way to do something like > > [header_commands, mysql_commands, dir_commands, scp_commands] each {|x| > f.puts x } > > I know there must be a number of ruby ways to do it. > > Any examples? You're almost there [header_commands, mysql_commands, dir_commands, scp_commands].each {|x| f.puts *x } You only missed a . and a *, that's it ;-) Regards Stefan -- Posted via http://www.ruby-forum.com/.