lua-users home
lua-l archive

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



On 2-Oct-06, at 2:37 PM, Jerome Vuarand wrote:


Workarounds:
- you can simply call yourself the comparison function instead of using the operator:
if foometatable.eq(foovar, 32) then foofunc() end
- you can cast one of your values to the same type as the other before the comparison operator is evaluated
if foovar==footype.new(32) then foofunc() end

Another possibility that suggests itself is:

  if foovar - 32 == 0 then ...

but that would only work if __sub were clever enough to return a (lua_Number) 0 instead of a (foo) 0. That might generally be a good idea, for numbers representable as lua_Numbers.