enum Test {
A = 100,
B = Test::A as isize * 100,
C = Test::B as isize * 100,
D = Test::C as isize * 100,
}
I was surprised to learn that something like this compiles. However why do I need to cast each of the case as isize
?
enum Test {
A = 100,
B = Test::A as isize * 100,
C = Test::B as isize * 100,
D = Test::C as isize * 100,
}
I was surprised to learn that something like this compiles. However why do I need to cast each of the case as isize
?
Because Test::A
is of type Test
, which can't be used with the multiplication operator. The cast gives you an integer instead.
This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.