Skip to main content
The 2024 Developer Survey results are live! See the results
edited title
Link
JustHeavy
  • 233
  • 1
  • 2
  • 8

LUA Lua: Storing a logical operator in a variable?

Source Link
JustHeavy
  • 233
  • 1
  • 2
  • 8

LUA: Storing a logical operator in a variable?

I can't find anything about this through Google so I have to ask here. I want to do something like this (very pseudo code):

y = first_value

x={op_1 = >, op_2 = <, c = some_value}

if first_value x.op_1 x.c then
...
end

What that code says to me is that if first_value if greater than x's c value then do something. Now, I know I could set op_1 and op_2 to some value to differentiate between them and then compare values using separate if statements, but I would like to minimize the number of if statements used.

I was just wondering if something like this is possible, maybe even in a different form. Thanks in advance!