From: Jeff Schwab Date: 2009-04-10T21:40:09+09:00 Subject: Re: Join strings Fresh Mix wrote: > What is the simples way to join strings? > > tmp1 = 'aa' > tmp2 = 'bb' > tmp3 = nil > tmp4 = nil > tmp5 = 'dd' > > result = 'aabbcc' Possibly: "#{tmp1}#{tmp2}#{tmp3}#{tmp4}#{tmp5}" If your needs are more complicated, maybe something like this: def join_tmp(indices, bind) eval "\"#{indices.collect {|i| "\#{tmp#{i}}" }.join}\"", bind end puts join_tmp(1..5, binding)