#Module Script Formatting

1 messages · Page 1 of 1 (latest)

delicate adder
#

Anyone know if there are any differences between these? and if I should pick and choose each for certain scenarios?

E.G 1

local module = {
   Function = function()
      print("Does this matter?")
   end
}
return module

E.G 2 (Function outside table v1)

local module = {}

function module.Function()
    print("Does this matter?")
end
return module

E.G 2.5 (Function outside table v2)

local module = {}

module.Function = function()
    print("Does this matter?")
end
return module

E.G 3 (Function outside table v3)

local module = {}

module:Function = function()
    print("Does this matter?")
end
return module
red prawn
#

ask ai

delicate adder
valid trout
#

no difference

#

it is just preferences

delicate adder
solemn willowBOT
#

studio** You are now Level 1! **studio

valid trout
#

the only difference between these is the Function outside table v3

valid trout
#

: makes it pass self as the first argument

#

you might want to search about self if you dont know about it yet

peak gazelle
#

Second example is mostly used and has more readability

#

Third example is used by entirely beginner

#

Second half example is used by someone who just starts at module

rotund dome
#

there are some differences depending on your types and where you write each one but for beginners just consider them all functionally the same.

peak gazelle
peak gazelle
#

like overrides.