[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: "or-ing" values
- From: v <v19930312@...>
- Date: Sun, 02 Feb 2020 22:00:10 +0300
On Sun, 2020-02-02 at 19:55 +0100, Peter Mueller wrote:
> 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?
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.