Case Insensitive Dictionary

Hey! I have a very simple release today. It’s just a normal dictionary, but all keys are case-insensitive (string keys only).

For example:

local dict : {string} = CaseInsensitiveDictionary.new()

dict.Foo = "bar"

print(dict.FOO, dict.fOo, dict.foo) -- bar bar bar

You can get the module here: CaseInsensitiveDictionary - Creator Store

I made this for admin commands, but it seems generally useful. Hope this helps someone!

2 Likes

What are the use cases for this? I cannot think of any situation where this would be needed.

4 Likes

You are right. You can just use a normal table while making sure to use lower() properly. It is essentially just syntax sugar.

The only way this is an improvement over using a normal table is that it allows autocomplete to work in more situations (which is important for me - I want others to be able to expand on my script easily).

For example, in my admin script I have tables which are not dynamic. They are instantiated with values and never change, they also have type definitions.

I was originally using lower() to index these tables, which resulted in the loss of autocomplete for reasons I could not figure out. So I made this module, and without changing any other code than the lines that create the tables, the autocomplete came back.

1 Like

Ah, that makes sense. Thanks for the explanation.

1 Like