lua-users home
lua-l archive

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

Unlike C[++], Lua’s assignment operation doesn’t produce a value in addition to moving bits from one location to another. So, what you are trying to do is not possible in Lua (aside from being less readable in general, IMO).


On the other hand I am surprised one can not say something along the lines








-----Original Message-----
From: Ando Sonenblick []
Sent: Wednesday, November 19, 2003 12:40 PM
To: Lua list
Subject: inline conditional assignment possible?


Hi gang,


I'm trying to assign a varible in an if statement and have its resulting value be evaluated for the if. For example:

Normal way:


s = project:FindSprite("Title")

if s ~= nil then

print("we have a title")



New desired way:


if (s = project:FindSprite("Title")) ~= nil then

print("we have a title")



But lua always complains and I've tried all sorts of syntactical variations. Is what I'm trying to do possible?