lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


On Thu, Apr 12, 2012 at 12:31 PM, Coda Highland <chighland@gmail.com> wrote:
> On Thu, Apr 12, 2012 at 10:26 AM, Jose Torre-Bueno <jtorrebueno@cox.net> wrote:
>> But I notice nan cannot be assigned to a variable, the variable is set to nil.
>
> That's because nan isn't a constant. It's just a variable that happens
> to be undefined. If you say "nan = 0/0" then it'll behave as you'd
> expect.

Indeed. A cool trolling exercise is to do
  nan = 1/0
  inf   = 0/0
  print(nan, inf) -- "inf, -nan" (for some reason, in my computer 0/0
is always -nan)

Reminds me of Python where, since all values are passed as reference, on can do
  True, False = False, True
on the middle of a huge source and laugh while every developer
desperately tries to track the bug.



-- 
NI!