Explaining complex variable

local x = …

local y = …

local z = …

local p = x < 5 and y or z.

Can anyone explain this complex variable p?

Are you familiar with C or C++?   Those languages have a statement called a ‘conditional’:
 
The statement you show is essentially the same concept:

local p = x \< 5 and y or z -- no period at end like you wrote...

This reads as:

  • Check if x is less than 5
  • If true, assign value in y to p
  • If falls, assign value in z to p

Another way to look at it is:

local var = (condition) and trueAssign or falseAssign

Finally, the one line statement above is equivalent to this much longer statement (which is why the short version is preferred by many):

local p if(x \< 5) then p = y else p = z end

PS - ‘p’ the variable is not complex. I assume you meant the statement looked complicated or complex to you. Complex is a mathematical that relates to numbers.  A variable cannot be complex.

Doing someones homework again Ed?

Are you familiar with C or C++?   Those languages have a statement called a ‘conditional’:
 
The statement you show is essentially the same concept:

local p = x \< 5 and y or z -- no period at end like you wrote...

This reads as:

  • Check if x is less than 5
  • If true, assign value in y to p
  • If falls, assign value in z to p

Another way to look at it is:

local var = (condition) and trueAssign or falseAssign

Finally, the one line statement above is equivalent to this much longer statement (which is why the short version is preferred by many):

local p if(x \< 5) then p = y else p = z end

PS - ‘p’ the variable is not complex. I assume you meant the statement looked complicated or complex to you. Complex is a mathematical that relates to numbers.  A variable cannot be complex.

Doing someones homework again Ed?