What Does a Table, Array, And a Dictionary Look Like?

Hi, :wave:

I’ve been very confused because people have many different answers of this. Thanks, :wave:

--Table
local fruits = {"Apple", "Bananas", "PineApple"}

--Dictionary
local dict = {
	["Fruit"] = "Apple",
	["Id"] = 53,
	["IsHungry"] = true
}

For arrays, there are 2 types of arrays from quick research, one-dimension and multi-dimension, Check this out for the array bit

2 Likes

Thanks but it says:

is an array. Isn’t it a table?

Technically Arrays can be considered as tables, later down the do mention an example of multi-diemsnional array

-- Initializing the array
array = {}

for i=1,3 do
   array[i] = {}
	
   for j=1,3 do
      array[i][j] = i*j
   end
	
end

-- Accessing the array

for i=1,3 do

   for j=1,3 do
      print(array[i][j])
   end
	
end

Which kinda looks like a dictionary to me

1 Like

Both dictionaries and arrays count as tables.

1 Like

Are multi-dimensional arrays similar to dictionaries.? Coz they kinda look same…but i think there is difference

Well judging from the way they look, they look like dictionaries, but I think they’re more so tables in a sense since they use regular indexing. So I think more so as tables

2 Likes