ComputerCraft Forums

ComputerCraft => Ask a Pro => Topic started by: TheTinyDeskEngineer on Apr 07, 2021, 11:27 PM

Title: .temp:8: 'do' expected near 'in'
Post by: TheTinyDeskEngineer on Apr 07, 2021, 11:27 PM
The error is coming from this line:
for s = 1, i in ipairs(whitelist) doI've done stuff like this before and it's never given this error. I don't think there's anything else needed, since it's complaining about something which should all be on this line.
Title: .temp:8: 'do' expected near 'in'
Post by: Lupus590 on Apr 08, 2021, 12:21 AM
You seem to have something that is halfway between the two valid types of for loop.

I believe that what you mean is.
for s, i in ipairs(whitelist) do
Title: .temp:8: 'do' expected near 'in'
Post by: redstonegenius on Sep 28, 2021, 08:10 PM
you don't use "s,"

when using the "in" keyword, the variable before it inherits whatever element is in the table

example

```
local arr = {1,2,3,"e"}
for a in arr do
 print(a)
end
```

will output

1
2
3
"e"

because "a" now inherits the whatever element you are currenly working on