This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
SpencerBeige's profile picture

list

Started by SpencerBeige, 14 February 2015 - 03:51 AM
SpencerBeige #1
Posted 14 February 2015 - 04:51 AM

t = {fs.list(path)}
for i = 1, #t do
  print(t[i])
end
doesn't return what i want
Dragon53535 #2
Posted 14 February 2015 - 04:59 AM
I believe fs.list returns a table. So basically you're seeing t[1] being a table.


t = fs.list(path)
for i = 1, #t do
  print(t[i])
end
SpencerBeige #3
Posted 14 February 2015 - 01:43 PM
I believe fs.list returns a table. So basically you're seeing t[1] being a table.
 t = fs.list(path) for i = 1, #t do print(t[i]) end 
that's the same thing i wrote down…whats wrong with the code i wrote?
Lignum #4
Posted 14 February 2015 - 02:04 PM
that's the same thing i wrote down…whats wrong with the code i wrote?
Your code:

t = {fs.list(path)}

Dragon's code:

t = fs.list(path)
MKlegoman357 #5
Posted 14 February 2015 - 02:06 PM
It's not the same code you wrote. What you are doing in your code is putting all return values of fs.list into a table, which you then save to a variable. What Dragon53535 is doing is putting the first (and only) return value into a variable. fs.list return a numerically indexed table, so there is no need to put it into another table.
SpencerBeige #6
Posted 14 February 2015 - 02:16 PM
ohhhhh ok