Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow foreach on 0-indexed arrays #2811

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions lua/entities/gmod_wire_expression2/core/array.lua
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@
-- Looped functions and operators
--------------------------------------------------------------------------------
registerCallback( "postinit", function()
local getf, setf

Check warning on line 68 in lua/entities/gmod_wire_expression2/core/array.lua

View workflow job for this annotation

GitHub Actions / lint

"Unused variable"

Unused variable: getf

Check warning on line 68 in lua/entities/gmod_wire_expression2/core/array.lua

View workflow job for this annotation

GitHub Actions / lint

"Unused variable"

Unused variable: setf
for k,v in pairs( wire_expression_types ) do
local name = k:lower()
if (name == "normal") then name = "number" end
Expand Down Expand Up @@ -231,14 +231,20 @@

local function iter(tbl, i)
local v = tbl[i + 1]
if not typecheck(v) then

Check warning on line 234 in lua/entities/gmod_wire_expression2/core/array.lua

View workflow job for this annotation

GitHub Actions / lint

"Syntax inconsistency"

Inconsistent use of 'not' and '!'
return i + 1, v
end
end

registerOperator("iter", "n" .. id .. "=r", "", function(state, array)
return function()
return iter, array, 0
if array[0] then
return function()
return iter, array, -1
end
else
return function()
return iter, array, 0
end
end
end)

Expand Down
Loading