From: Jagadeesh Date: 2009-05-26T00:50:25+09:00 Subject: Re: String concatenation in Ruby On May 25, 1:30 pm, Robert Klemme wrote: > 2009/5/25 Mohit Sindhwani : > > > Jagadeesh wrote: > > >> Hi, > >> I am looking for something similar to join in perl. I am doing > >> [sample perl code] > > >> $CMD = join('  ',  $cmd, $arg1, $arg2, $arg3); > > > Not 100% sure of what you need, but I think this will do the job for you: > > str = [cmd, arg1, arg2, arg3].join(' ') > > Alternative approaches: > > str = "#{cmd} #{arg1} #{arg2} #{arg3}" > str = sprintf '%s %s %s %s', cmd, arg1, arg2, arg3 Robert, I love this approach. It makes my code more readable. Will use it. Thanks > > If this is for executing an external process, there is no need to lump > all these together, instead you can do which has the advantage that > you do not need a shell to parse the individual arguments and also > whitespace cannot cause trouble. > > system cmd, arg1, arg2, arg3 > > Kind regards > > robert > > -- > remember.guy do |as, often| as.you_can - without endhttp://blog.rubybestpractices.com/