Gavin Kistner
7/2/2007 4:50:00 AM
On Jun 28, 3:46 am, Robert Klemme <shortcut...@googlemail.com> wrote:
> On 28.06.2007 07:35, Phrogz wrote:
> > File.new( configfile, File::CREAT|File::WRONLY, 0700){ |f|
> > f.puts [ header_commands, mysql_commands, dir_commands,
> > scp_commands ].flatten
> > }
>
> 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
*slaps hand to forehead*
I got all caught up in thinking that Ruby allowed multiple splats per
function/array
e.g. puts [ *a1, *a2, *a3, *a4 ]
and didn't step back to think about what was possible.
I'm happy to see that 1.9 will support multiple splats as rvalues and
in method calls. I hope/assume this also applies to splatting in an
array literal. (Not that what I was trying is as good as the
simplicity Robert has provides.)
--
(- /\ \/ / /\/