I’m trying to answer myself the point of end) or end. I’ve been wanting to know and I’ve been questioning myself: What’s the point of end? This might be the wrong topic.
If end is to end the script then: Why can’t we have multiple ends? After answering that, can you also tell me the difference between end and end)?
Again, I think this might be in the wrong topic so please tell me if it is.
end) is used to close a statement where a function is used, e.g
pcall(function()
end) -- pcall takes a function argument and is closed by the )
function()
end -- <- no ) because you are not closing anything
--if it helps, the pcall statement is equal to
pcall(function() end)
My post isn’t a good reference for this thread since it tackles a different issue but I guess some of the wording is applicable in the sense of what an end is. That being said, there’s no difference between either. The closing parenthesis is put there in order to close an open one. Parenthesis need to match: if you have an open one you also need a closed one.
End declares the end of a scope. Anything you open must be matched with a closer. end closes a scope. A closed parenthesis closes an open parenthesis. It’s all about matching. Other languages have this as well but some may not feature an explicit keyword for it.