Can you please tell me what a table is?
This is a read-only snapshot of the ComputerCraft forums,
taken in April 2020.
What is a table?
Started by FoxData, 15 March 2016 - 02:50 PMPosted 15 March 2016 - 03:50 PM
Hi everyone. I have no idea what a table is. I know what a database table is. But not what a lua table is.
Can you please tell me what a table is?
Can you please tell me what a table is?
Posted 15 March 2016 - 04:16 PM
You're on the internet, there are plenty of sites which explain it. You just have to do a quick Google search. If you have questions about certain aspects, we're happy to answer them, but I doubt anyone would take the time to write up a post explaining the entire concept of tables.
Posted 15 March 2016 - 04:46 PM
A lua table is something between a hashmap and an array.
In essence, a table associates two things. For example, a number with a string. Or vice versa. The value can be anything, a function, a coroutine, even another table!
Tables are useful when you want to organize some things. All APIs are actually tables, when you call os.pullEvent you are indexing the table os, with they key "pullEvent". The function associated with that key is then called.
Tables are also useful when you have an unknown or large amount of values to store. For example, if I was to create a coroutine manager, I would need to store whichever programs the user might launch. However, I don't know how many will be active at any given point.
Ignore this:
This just doesn't make any sense.
In essence, a table associates two things. For example, a number with a string. Or vice versa. The value can be anything, a function, a coroutine, even another table!
Tables are useful when you want to organize some things. All APIs are actually tables, when you call os.pullEvent you are indexing the table os, with they key "pullEvent". The function associated with that key is then called.
Tables are also useful when you have an unknown or large amount of values to store. For example, if I was to create a coroutine manager, I would need to store whichever programs the user might launch. However, I don't know how many will be active at any given point.
Ignore this:
A table is an index where you can store multiple items
This just doesn't make any sense.
Is this the proper response?Ok this is scary at 05:46 PM you quoted something that was said at 06:23 PM
Edited on 22 March 2016 - 09:27 PM
Posted 15 March 2016 - 05:23 PM
A table is an index where you can store multiple items
Posted 22 March 2016 - 08:32 PM
A lua table is something between a hashmap and an array.
In essence, a table associates two things. For example, a number with a string. Or vice versa. The value can be anything, a function, a coroutine, even another table!
Tables are useful when you want to organize some things. All APIs are actually tables, when you call os.pullEvent you are indexing the table os, with they key "pullEvent". The function associated with that key is then called.
Tables are also useful when you have an unknown or large amount of values to store. For example, if I was to create a coroutine manager, I would need to store whichever programs the user might launch. However, I don't know how many will be active at any given point.
Ignore this:A table is an index where you can store multiple items
This just doesn't make any sense.
Ok this is scary at 05:46 PM you quoted something that was said at 06:23 PM
Posted 22 March 2016 - 09:33 PM
Ok this is scary at 05:46 PM you quoted something that was said at 06:23 PM
the power of being able to edit your post after you posted it
Edited on 22 March 2016 - 08:33 PM
Posted 22 March 2016 - 11:33 PM
Lock this thread
Posted 23 March 2016 - 08:46 AM
Lock this thread
The mods don't like locking threads in ask a pro, just in case someone else has the same/similar question