#Confused about dictionaries

1 messages · Page 1 of 1 (latest)

gritty torrent
#

I've been reading about dictionaries (mostly about how to insert values) but the more I read about them, the more confused I get.

Are dictionaries and arrays two different data types? or are dictionaries just a array that's using values for it's indexes. I tried reading the documentation, and maybe this is me being stupid, but that didn't clear anything up. Any help is appreciated!

#

and also on a side note, whats the difference between putting script inside the module script table, vs outside it?

local module = {
  --here
}
-- vs here

return module
vernal mica
#

a dictionary is a table with key value pairs

#
local dict = {
  key = "hi"
}```
#

you index a dictionary with a key instead of an index (array)

#

the keys can be either just text key or string ["String key"]

#

the value can be any datatype

#

and it can be mixed as well

#

typechecking a dictionary goes like

#
local dict: {[string]: BasePart} = {}
#

a key is a string and the value is a basepart

#

anything else

vernal mica
#

it all just returns the table

#

when you do function module.function()

gritty torrent
# vernal mica anything else

nope, thats all! thank you so so much for the extremely in-depth expleanation, some of that had been confusing me for so long lmao.

vernal mica
#

youre just inserting into the moduel table a function

vernal mica
#

so its teh same as local module = {a = function() end}

vernal mica
#

the different methods of inserting stuff into module tables

#

has different performance

#

but its not noticeable

#

dont worry about it

#

unless you want to micro optimize

#

(boo)

gritty torrent
#

lmao, good to know

fossil juniper
vernal mica
#

always s1s arguing over picoseconds

fossil juniper
# vernal mica always s1s arguing over picoseconds

i’m not arguing for them to optimize anything, i’m making the statement that learning how to optimize and use good habits as early as possible is way better than having to replace poor habits later.

#

no need to be aggressive.

vernal mica
#

optimize

#

not microoptimize

#

son

fossil juniper
#

so you disagree with my point that you should learn good habits over bad habits?

#

what are you even talking about.

fossil juniper
vernal mica
vernal mica
#

u just had to put ur two cents in

#

for no reason

fossil juniper
vernal mica
#

❤️‍🩹

#

sorry

timid ledge