Julia: Enum doesn't display UInt8 correctly

Created on 7 May 2018  路  3Comments  路  Source: JuliaLang/julia

Hello,

Enum doesn't display UInt8 correctly

julia> @enum(MyEnum::UInt8,
  A=0x00,
  B=0x01,
  C=0xf0,
)

julia> Base.Enums.basetype(MyEnum)
UInt8

julia> MyEnum
Enum MyEnum:
A = 0
B = 1
C = 240

althought

julia> Base.Enums.basetype(MyEnum)(C)
0xf0

I was expecting

julia> MyEnum
Enum MyEnum:
A = 0x00
B = 0x01
C = 0xf0

Kind regards

display and printing

Most helpful comment

Should be easy to fix, would you like to try making a pull request? In base/Enum.jl, the Base.show method should call show instead of print when printing the integer codes of values.

All 3 comments

Should be easy to fix, would you like to try making a pull request? In base/Enum.jl, the Base.show method should call show instead of print when printing the integer codes of values.

Hi, I would like to work on this issue if @scls19fr doesn't want

Thanks @guilhermeleobas you can do it if you want

Was this page helpful?
0 / 5 - 0 ratings