Logo

Programming-Idioms

History of Idiom 53 > diff from v46 to v47

Edit summary for version 47 by laowang:
[Lua] ok

Version 46

2017-08-11, 08:14:18

Version 47

2017-09-17, 12:12:27

Idiom #53 Join a list of strings

Concatenate elements of string list x joined by the separator ", " to create a single string y.

Illustration

Idiom #53 Join a list of strings

Concatenate elements of string list x joined by the separator ", " to create a single string y.

Illustration
Code
for _, v in ipairs(x) do
	if y then
		y = y .. ', ' .. v
	else
		y = v
	end
end
Code
y = table.concat(x, ", ")