Lua string.format options

Viewed 82317

This may seem like a stupid question, but what are the symbols used for string replacement in string.format? can someone point me to a simple example of how to use it?

4 Answers

To add to the other answers: Lua does have a boolean data type, where C does not. C uses numbers for that, where 0 is false and everything else is true.

However, to format a boolean in a String in Lua,

local text = string.format("bool is %d", truth)

gets (at least in Hammerspoon):

bad argument #2 to 'format' (number expected, got boolean)

You can instead use %s for booleans (as for strings):

local text = string.format("bool is %s", truth)
Related