Lua 学习笔记(5)字符串缓冲

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/l773575310/article/details/82948207

Lua 学习笔记(5)字符串缓冲

《Lua程序设计》


字符串缓冲

-- 传统读代码
local buff = ""
for line in io.lines() do
	buff = buff .. line .. "\n"
end

-- 优化
local t = {}
for line in io.lines() do
	t[t# + 1] = line .. "\n"
end
local s = table.concat(t)

猜你喜欢

转载自blog.csdn.net/l773575310/article/details/82948207