lua-users home
lua-l archive

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


On Sun, 2020-02-02 at 19:55 +0100, Peter Mueller wrote:
> Hello,
> 
> I try to port some code from C to Lua.
> 
> There is some code similar to this (simplified).
> 
>   ...
>   unsigned char var=0;
>   var |= function1();
>   var |= function2();
>   return var
> }
> 
> How would I implement the |= in Lua?
> 
> Thanks,
> Peter
> 

Is that a logical `or` (on bools) or numerical one (on numbers)?

First one would be `var = var or function1()`
Second one is `var = var | function1()` since Lua 5.3
or `var = bit32.bor(var, function1())` in Lua 5.2/LuaJIT.
-- 
v <v19930312@gmail.com>