Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

What are the advantages of weak tables and use cases of making them weak?

Asked by 4 years ago

I had posted this a while back but got no answers so here I am reposting!

Disclaimer

I know what a weak table is, just looking for use cases for them.

Question

From my understanding, you can set the values of a table to be weak with like this:

local x, m = {}, {__mode = 'v'}
setmetatable(x, m)

You can also set the keys to be weak with __mode = 'k' and both the keys and values with __mode = "kv".

So my question is this:

What are weak tables useful for? Will I find myself using them in the future?

1
Side note: Do not answer this question unless you 100% know what you're doing. We don't want a repeat of random people dishing out stupid answers. DeceptiveCaster 3761 — 4y
0
I don't have time to write a full answer today, but I can answer the final question: "Will I find myself using them in the future?" > No, you very probably won't. BlueTaslem 18071 — 4y

Answer this question