Why would I like to list matlab enum in int32?

Today I went into this piece of code:

classdef (Enumeration,Sealed) ClassBlabla < int8 enumeration ALPHA(0) BETA(1) GAMMA(2) end methods (static) function ret = doSomething() ret = containers.Map(.......) for i = int32(ClassBlabla.ALPHA):int32(ClassBlabla.GAMMA) ret(i) = somethingelse(blablabla(i)) end end end end 

What is int32 (...) in for? Cast? Why do I want to use int32? Is ALPHA already 0 and GAMMA is already 2 ??

+4
source share
1 answer

To extend the ALPHA and GAMMA values ​​from int8 to int32 . Most likely, this is because either the blablabla() function expects an int32 input, or it is expected that the ret value has int32 keys. ALPHA and GAMMA are already 0 and 2, but they are int8 instead of int32 , and blablabla() or doSomething() clients can play poorly with int8 values. (You can say that ALPHA and GAMMA int8 due to ClasBlabla < int8 at the top.)

+2
source

All Articles