r/programminghumor • • 15d ago

Lua

Post image
3.1k Upvotes

168 comments sorted by

View all comments

Show parent comment

3

u/ScallionSmooth5925 14d ago
foo = {}
foo[1]=1
foo["appletree"]=2
for k, v in pairs(foo) do 
print("foo[" .. k .. "]=" .. v )
end

0

u/ilmaestrofficial 14d ago

I just wanted to know what an array is 😭

5

u/Hipnotize_nl 14d ago

A table. Like everything in lua

2

u/Logogram_alt 14d ago

A array is a ordered list of eliments. For example in pseudocode

A = [1, 2, 3, 4]

#this is a array

#in a 0-indexed array

A[0] == 1

#in a 1-indexed areay

A[1] == 1

1

u/soggycheesestickjoos 14d ago

it’s a list of things. “one” is just a string/text, [“one”, “two”, “three”] is an array of strings/text.