patternMinor
Consolidating array accesses
Viewed 0 times
arrayconsolidatingaccesses
Problem
Is there a better or easier way of doing this?
I have a lot of arrays to check and was wondering if there is a way to work with arrays where you can do something like
if array[1] and array[2] and array[3] and array[4] and array[5] == false then
--somthing
endI have a lot of arrays to check and was wondering if there is a way to work with arrays where you can do something like
array[1-6] or [1,6] or something. Can't seem to find anything online.Solution
I'm not sure of the lua syntax but something like
arrayAllFalse=TRUE;
for element in array
if (element) then
arrayAllFalse=FALSE
end
if (arrayALLFalse) then
--something
endCode Snippets
arrayAllFalse=TRUE;
for element in array
if (element) then
arrayAllFalse=FALSE
end
if (arrayALLFalse) then
--something
endContext
StackExchange Code Review Q#8468, answer score: 2
Revisions (0)
No revisions yet.