[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: string.format a nil value
- From: "jason zhang" <jzhang@...>
- Date: Thu, 24 Aug 2006 16:26:00 +0800
How about producing a empty string?
string.format("Number is %d",data) ==> Number is
----- Original Message -----
From: "Andreas Stenius" <email@example.com>
To: "Lua list" <firstname.lastname@example.org>
Sent: Thursday, August 24, 2006 4:09 PM
Subject: Re: string.format a nil value
> jason zhang skrev:
>> string.format("%d",novalue), where novalue is a nil variant.
>> Why not outputing a "NIL" like string? It think it's not very friendly
>> to print a error information and
> Because code that uses the output may rely on the facy that it should be
> a valid number, since %d was used. If you want "nil" to come out of it,
> i would recommend trying:
> string.format("%s", tostring(novalue))
> Which will work as expected for numbers as well (altough you'll get the
> fraction part as well, which isn't what you'd get with %d)..