|
| 09 Mar 2017 09:35 AM |
Is a table a 1 dimensional array that also behaves like a class?
|
|
|
| Report Abuse |
|
|
| |
|
| |
|
AxonMega
|
  |
| Joined: 29 Aug 2014 |
| Total Posts: 2403 |
|
|
| 09 Mar 2017 09:42 AM |
| Tables are data structures that behave like objects and can be arrays of any dimension or dictionaries, or even both at the same time. |
|
|
| Report Abuse |
|
|
|
| 09 Mar 2017 09:44 AM |
Although you can simulate a table to be a multi dimensional array by putting multiple 1 dimensional tables in a table, I'm pretty sure that doesn't mean they are multi dimensional.
Also what do you mean with dictionaries?
|
|
|
| Report Abuse |
|
|
AxonMega
|
  |
| Joined: 29 Aug 2014 |
| Total Posts: 2403 |
|
|
| 09 Mar 2017 09:50 AM |
What's the difference between simulating a multi-dimensional array and being one?
Also, dictionaries are tables in which the keys are more than just integers. They can be strings, booleans, and I think every other type of data in Lua except nil.
Example:
dictionary = { [true] = false, ["Cat"] = "Dog", [12] = 24 } |
|
|
| Report Abuse |
|
|
|
| 09 Mar 2017 09:52 AM |
@Axe Not much, except that one is easier to create and is a bit more optimized.
And thanks for the explaination.
|
|
|
| Report Abuse |
|
|
AxonMega
|
  |
| Joined: 29 Aug 2014 |
| Total Posts: 2403 |
|
| |
|
cntkillme
|
  |
| Joined: 07 Apr 2008 |
| Total Posts: 44956 |
|
|
| 09 Mar 2017 02:08 PM |
"Is a table a 1 dimensional array that also behaves like a class?" No. It's far more generic than that.
A table is really just hash map in which keys can be any Lua value other than nil. They are optimized for array usage, however (values in integral keys from 1 to n are typically in the array part which makes it faster to read and write to). |
|
|
| Report Abuse |
|
|
| |
|