lua-users home
lua-l archive

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


In message <53654.78106.qm@web81604.mail.mud.yahoo.com> you wrote:

> Ok, let me try this again.
> 
> I have code that says something like:
> 
> if X[1944] == "" or X[1944] == 0 then X[1944] = 9999  
> end
> 
> I want this to work as intended, i.e., if the value of
> X[1944] is "" or 0, then it will be changed to 9999.
> However, I don't have any way of telling whether the
> existing value of X[1944] is a string or a number. I
> have hundreds of these expressions, and don't want to
> change each one to test the type of the variable
> before doing the comparisons. Is there any way to do
> this without modifying all these expressions?

The statement is fine as it stands. == is happy to compare
anything. If for some other reason you need to know
whether X[1944] is a string or a number you can always use
the "type" function.
-- 
Gavin Wraith (gavin@wra1th.plus.com)
Home page: http://www.wra1th.plus.com/