From: "Gonzalo Garramuño" Date: 2007-12-24T12:54:29+09:00 Subject: Re: 1.9 problem with function *args parameters. Yukihiro Matsumoto wrote: > > Try explicit hash like: > >> FileUtils.cp_r(src, dest, {:verbose => true}, *opts) rescue nil > > 1.9 only allows hash without braces at the very last of the > arguments. > I thought I was doing that, but it is clearly not what the parser thinks (neither in 1.8 or 1.9). I was expecting that just splatting the arguments would then consider all the last arguments as a flattened array and thus a (merged) hash. Thus, the issue is more than a syntax problem, but a logic one. Sadly, the only way to achieve the behavior I am looking for is really still this ugly stuff. def cp_r( src, dst, opts = {} ) FileUtils.cp_r( 'src', 'dst', { :verbose => true }.merge(opts) ) rescue end Which is yucky and slow as the merge is done explicit instead of implicit by the interpreter. I'm thinking this maybe this should be a feature request. To have some simple syntax like: def cp_r( src, dst, *opts ) FileUtils.cp_r( 'src', 'dst', :verbose => true, *opts ) end to be interpreted as a single merged hash at the end. Perhaps the splat operator is not the best syntax or operator, thou. I think the idiom of needing merging hashes as parameters are passed is way too common to deserve some syntax. -- Gonzalo Garramu�o ggarra@advancedsl.com.ar AMD4400 - ASUS48N-E GeForce7300GT Xubuntu Gutsy