Enum:FromName(...) vs Enum[...]

I was just doing random stuff until I came across the former and I started thinking “Why does that even exist?”

I mean doesn’t Enum[...] do the same thing?

Example:

print(Enum.KeyCode:FromName("E")) -- Enum.KeyCode.E
print(Enum.KeyCode["E"]) -- Enum.KeyCode.E

Somebody please explain :pray: Thanks

Never mind, FromName does not error if you access something that does not exist unlike directly accessing it Sorry for the inconvenience
image

1 Like