문제

I have an enumerator type:

enum PlayerProps {
    Attempts;
    Gold;
    Diamonds;
}

What should I do to iterate through all enum values? Something like:

var props = new Map<PlayerProps, Int>();
for (prop in PlayerProps)
    props[prop] = 0;
도움이 되었습니까?

해결책

What you are looking for is Type.allEnums():

for (prop in Type.allEnums(PlayerProps))

Working example on try.haxe.org.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top