Saturday, 7 September 2013

What is the boolean interpolation character for string.format function in lua

What is the boolean interpolation character for string.format function in lua

I'm looking for a boolean interpolation character for string.format(as the
title says).
I want something that will work this way:
print(string.format("nil == false: %b",(nil==false))
%b is just a placeholder, you'll get an error with that. I'm looking for
'b'. I can't just do:
print("nil == false: " .. (nil==false))
because booleans can't be concatenated with strings. I could do:
val=(nil==false)
if val==false then truth="false" else truth="true" end
print("nil==false: ".. truth)
But it's too much work.

No comments:

Post a Comment