Hiya,
I have this OOP module which creates a new party, but I’m wondering if this is an okay way to format/check arguments.
Not only is the default assert()
slow, but it’s also pretty ugly syntactically (In my opinion).
My question is, if you were to read this module and try to understand it, would you think this is a good way to custom assert arguments?
Code:
function Party.new(Id :string, Name :string, Leader :Player)
local self = setmetatable({}, Party)
-- Properties --
self.Id = Id or error(debug.traceback("No id provided to create party."))
self.Name = Name or error(debug.traceback("No name provided to create party."))
self.Leader = Leader or error(debug.traceback("No leader provided."))
self.Members = {Leader}
Screenshot in code editor: