Well to me parameters are things that can be overridden/used for later.
even if it’s not today’s question I also wanted to know if what I said is true.
So I wanted to know how to read and understand the text inside brackets:
For this: (I may have misunderstood something however)
pairs is simply looking for a Table as stated below the Parameters
When People use GetChildren or GetDescendants: GetChildren returns a table of the children within a Object
GetDescendants returns a table of Every single Item within a Object
Example:
TableOfStuff = {"Apple", "Orange"} -- Table
for i, p in pairs(TableOfStuff) do
print(i) -- Prints the Number of Objects
print(p) -- prints the Object
end
I may be wrong about this so feel free to correct me
so … is just all arguments passed into the function
for example print("hello", "hello2") will output hello hello2 the print function will automatically take alll of the arguments (arguments are things separated by commas passed into a function) and combine them into one string
when you see a colon after something, for example name: string that is is the type the function expects it to be
for example: a function called FindFirstChild expects a string for the name of the child you wish. a string is something surrounded by quotes, double or single. :FindFirstChild("name here")
when things get more complicated such as the pairs function. the types are weird looking because of how roblox set it up.
pairs() takes any tupe of table and that is what the type (thing after the colon (:)) is saying
now when you see a question mark after a type that means its an optional argument
for example: the Instance.new() function. it takes a required argument of the class and an optional argument of its parent to set to. Instance.new(className: string, parent: Instance?)
finally the colon at the very end of the function print(...: T...): () what it is, is whatever the function returns
for example: a function that returns a number would look like this function(): number
here are some examples of custom functions that use this type stuff
-- function that takes a list of BaseParts and returns a boolean (true/false)
function AnyTouching(list: {BasePart}): boolean
-- function that searches for a name (idk these are just examples) and returns a bool if found
function Search(name: string): boolean
Parameters are just bits of data (variables). Those bits of data can be different types.
You can pass variables to sections of purposeful code (functions) as parameters (/ arguments).
These parameters are local to the function they’re passed to. After the function exits (returns), those variables are collected and garbaged (garbage collection), though this is an oversimplification.
print accepts parameters. Within Lua, there’s a function:
function print(...)
for k, v in pairs({...}) do
io.write(v)
end
end
Again, an oversimplification, though fundamentally parameters are just variables local to whatever they’re being passed to.
When u say :Instance.new(className: string, parent: Instance?)
so that means that the first argument is what the parameters expects from us. And that after the comma it’s optional?
And when the parameters include : () this mean we can put any thing and we don’t care what is inside bracket , and finnaly if we don’t have : ()
but : number this mean we need to put a number inside the bracket.