Join strings

F

Fresh Mix

What is the simples way to join strings?

tmp1 = 'aa'
tmp2 = 'bb'
tmp3 = nil
tmp4 = nil
tmp5 = 'dd'

result = 'aabbcc'
 
L

Leo

result = 'aabbcc'

local_variables.select {|v| v != '_'}.map {|v| eval(v)}.join
=> "aabbdd"

Unfortunately, I don't know where you got the "cc" from in your
example.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,175
Messages
2,570,947
Members
47,498
Latest member
yelene6679

Latest Threads

Top