Jeff Schwab
4/10/2009 12:36:00 PM
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)