Consistency when using EnumItem name or value

When setting an EnumItem property on an instance, you can set it to the EnumItem, the name of the EnumItem, or the value of the EnumItem.

Baseplate.Material = Enum.Material.Concrete
Baseplate.Material = "Concrete"
Baseplate.Material = 816

Will all set the baseplate’s material to Concrete.
However, this isn’t the case for the constructors of some data types.

Axes - Doesn’t work with EnumItem name, or EnumItem Value.
DockWidgetPluginGuiInfo - Doesn’t work with EnumItem name
Faces - Doesn’t work with EnumItem name, or EnumItem Value.
PathWaypoint - Doesn’t work with EnumItem name, or EnumItem Value.
PhysicalProperties - Doesn’t work with EnumItem name, or EnumItem Value.
TweenInfo - Doesn’t work with EnumItem name

5 Likes

Could you elaborate further on which properties don’t work with enum names and values? (Any example of script and it’s result)

At the moment the only method I have in mind that could not work witu those is ContextActionService:BindAction as it allows to bind it using either Enum.KeyCode or Enum.UserInputType.

That’s because the things you just listed aren’t Enums, they’re atomic data types. Enums have a lot of special behavior that the other atomic data types don’t (and in some cases, can’t) have.

Is what you’re asking for to be able to make a string based assignment like this:

part.Position = "123, 4.5, 6"

There’s a good reason that you can’t do that, because the string representation of a value may be locale dependent. It’s also not very forward compatible because it breaks if we ever want to change the string representation of one of the types.

2 Likes

No.

I’m asking about using EnumItem name/value when constructing certain data types.

For example:

local info = TweenInfo.new(1,"Quad","Out",0,false,0)

or

local Axes = Axes.new(0,1,2)

Yeah, sorry for the confusion.

This is going to be a WontFix, as we’re likely going to be soft-deprecating implicit enum casts like that soon. (Soft deprecating = not supporting it on new types, but never actually removing it because so much existing stuff relies on it)