Which should I use? And why? How do they differ (if they do)?
I may be wrong, but I am pretty sure that’s just preference.
Both do the same thing, it’s just “Syntax sugar” made to make code more pleasant to read for some people.
Its all based on preference but I would advise you to use the second method because its more syntactically pleasing.
And the second method allows you to use the colon :
instead of the period .
, which allows you to make use of the keyword self
to reference the module rather than referencing it by name.
And yes, I’m aware you can achieve the same thing using:
Module.Spawn = function(self, ...)
end
Module:Spawn()
But imo the below one is much more better:
function Module:Spawn()
end
Module:Spawn()
thank you, I was stressing that I may be doing something wrong
thank you for clearing this up
since it is all preference, I’d stick with the first one; thank you for clearing it up for me
But as you progress further almost always you will use the second method but hey thats jus an opinion, you r free to do wtever you lik
To be honest, they are the same thing. You should use what you prefer. Personally, I like
function function_DICTIONARY.spawn()
It’s easier to see the function command and stuff.
why does no one like function_DICTIONARY.spawn =function() it looks so clean tho ):
thank you for your answer as always!