Comparison

util/format.lua @ 8417:e88db5668cfb

util.format: Import unpack from table lib in Lua 5.2+
author Kim Alvefur <zash@zash.se>
date Thu, 23 Nov 2017 20:55:21 +0100
parent 8383:d967d6f2ad00
child 9656:3da6cc927ee6
comparison
equal deleted inserted replaced
8416:bc9cb23b604a 8417:e88db5668cfb
2 -- A string.format wrapper that gracefully handles invalid arguments 2 -- A string.format wrapper that gracefully handles invalid arguments
3 -- 3 --
4 4
5 local tostring = tostring; 5 local tostring = tostring;
6 local select = select; 6 local select = select;
7 local unpack = unpack; 7 local unpack = table.unpack or unpack; -- luacheck: ignore 113/unpack
8 local type = type; 8 local type = type;
9 9
10 local function format(formatstring, ...) 10 local function format(formatstring, ...)
11 local args, args_length = { ... }, select('#', ...); 11 local args, args_length = { ... }, select('#', ...);
12 12