Re: "or-ing" values
[
Date Prev][
Date Next][
Thread Prev][
Thread Next]
[
Date Index]
[
Thread Index]
- Subject: Re: "or-ing" values
- From: v <v19930312@...>
- Date: 2020年2月02日 22:00:10 +0300
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>