Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help,
read this.
-
noatom
- Prole
- Posts: 10
- Joined: Sun Feb 17, 2013 9:51 pm
Post
by noatom »
If I have this:
Code: Select all
t[2] = { "apple", "pear", "banana" }
how should I acces pear? t[2][2] or t[2].pear? Could I do this: t[2][2] = { "inception" } ?
And most importantly,what would happen if i'd run a loop to go through t? what would it output when it got to t[2]? cause t[2] has 3 elements!
-
spectralcanine
- Citizen
- Posts: 65
- Joined: Sat Dec 22, 2012 8:17 am
Post
by spectralcanine »
Why not try it out?
print(t[2][2]) -- hint: it will print "pear"
Why does it matter in a loop that one of the elements is another table? you can use tables anywhere you want.
-
Qcode
- Party member
- Posts: 170
- Joined: Tue Jan 10, 2012 1:35 am
Post
by Qcode »
If you wanted it to print t[2].pear then you would have to do
Code: Select all
t[2] = {apple = "apple", pear = "pear", banana = "banana"}
Users browsing this forum: Ahrefs [Bot], Bing [Bot], Google [Bot] and 3 guests