The devhub page for metatables is extremely confusing and I’m not sitting through a 30 minuted youtube commentary about metatables. I want a straight answer. How do I use metatables, what is it used for, and what can it do that regular tables can’t.
The way this is worded makes it sound like you need a metatable to do something like {print, function() end, math.cos}. You can put a function into tables without metatables, metatables just expand the functionality of tables (e.g. allowing you to add them)
Awesome’s links have more info on the specifics of how, but basically you can use metatables to define custom behavior for tables, including the ability to add them. So something like {1, 2, 3} + 4 --> {1, 2, 3, 4} could be doable if the first table had a metatable with an __add function that makes it do that. You can pretty much just define your own behavior for any operator, including stuff like table.x = y and table.x (getting and setting, which is the most common use for them).