lua-users home
lua-l archive

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

On Thu, Jul 14, 2022 at 4:20 PM Jasper Klein <> wrote:
For example when checking if a permission is set;

if variable_with_permissions & ~perms.owner_write == perms.owner_write then
        -- ...

1) The '== perms.owner_write' part is required because an if-statement evaluates uservalues as true.
      '__eq' metamethod is only called when both operands are a table or userdata.

2) The '&' and '~' operators create a new uservalues that are immediately garbage.

To solve the boolean issue, I would suggest adding a method to `perms` objects. Example:

if perms.owner_write:in(variable_with_permissions) then
    -- ...

...except `in` is a reserved keyword and I don't know what would best replace it. (Naming things is hard!)