Replies: 1 comment
-
Support for this was added in commit 2c86ae0 require 'string'
local MyEnum: type = @enum{A = 0, B}
function MyEnum.__tostring(value: MyEnum): string
## for i,field in ipairs(value.type.fields) do
if value == #[field.value]# then
return string.copy(#[value.type.nickname..'.'..field.name]#)
end
## end
return string.copy('Unknown')
end
print(MyEnum.A) -- outputs: MyEnum.A Note that I've used |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Like __tostring so we can print enum easily
Beta Was this translation helpful? Give feedback.
All reactions