# Enums

**URL:** <https://forum.makecode.com/t/enums/4709>\
**Category:** Help\
**Created:** [November 30, 2020, 7:44pm UTC](https://forum.makecode.com/t/enums/4709 "2020-11-30T19:44:28Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![GameGod](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/gamegod/32/2756_2.png) [@GameGod](https://forum.makecode.com/u/GameGod)\
**Post date:** [November 30, 2020, 7:44pm UTC](https://forum.makecode.com/t/enums/4709/1 "2020-11-30T19:44:28Z")

</div>

I have an enum, how do I check the result?

I tried an if choice = left. It didn’t work.

---

<div class="post-metadata">

**Author:** ![shakao](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/shakao/32/113_2.png) [@shakao](https://forum.makecode.com/u/shakao)\
**Post date:** [November 30, 2020, 7:52pm UTC](https://forum.makecode.com/t/enums/4709/2 "2020-11-30T19:52:00Z")

</div>

Hm, are you doing “=” or “==” ? Something like this seems to work for me:

```auto
enum Test {
    One, 
    Two
}

// Randomly choose One or Two
let a: Test = randint(0, 1) == 1 ? Test.One : Test.Two;

if (a == Test.One) {
    game.splash("One")
} else if (a == Test.Two) {
    game.splash("Two")
}

```

---

<div class="post-metadata">

**Author:** ![GameGod](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/gamegod/32/2756_2.png) [@GameGod](https://forum.makecode.com/u/GameGod)\
**Post date:** [November 30, 2020, 7:56pm UTC](https://forum.makecode.com/t/enums/4709/3 "2020-11-30T19:56:50Z")

</div>

I am doing two, let me revise my code…

---

<div class="post-metadata">

**Author:** ![GameGod](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/gamegod/32/2756_2.png) [@GameGod](https://forum.makecode.com/u/GameGod)\
**Post date:** [November 30, 2020, 8:00pm UTC](https://forum.makecode.com/t/enums/4709/4 "2020-11-30T20:00:29Z")

</div>

![image](https://us1.discourse-cdn.com/flex020/uploads/makecode/original/2X/f/f1bfe26f9e5df084cb5b53bbbd41089e9ae50533.png)  
Here it is, what am I doing wrong?

---

<div class="post-metadata">

**Author:** ![shakao](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/shakao/32/113_2.png) [@shakao](https://forum.makecode.com/u/shakao)\
**Post date:** [November 30, 2020, 8:05pm UTC](https://forum.makecode.com/t/enums/4709/5 "2020-11-30T20:05:46Z")

</div>

Two things! First, you should be checking `if (direction == Test.left)`. Second, you’ll need to change the name of either the function or the namespace–right now, all of them are “Test” which will confuse the compiler. You could have something like “TestNamespace” and “TestFunction”, so that they are also distinct from your `Test` enum.

---

<div class="post-metadata">

**Author:** ![GameGod](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/gamegod/32/2756_2.png) [@GameGod](https://forum.makecode.com/u/GameGod)\
**Post date:** [November 30, 2020, 8:06pm UTC](https://forum.makecode.com/t/enums/4709/6 "2020-11-30T20:06:30Z")

</div>

Thanks!

---

<div class="post-metadata">

**Author:** ![YuHayate](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/yuhayate/32/8275_2.png) [@YuHayate](https://forum.makecode.com/u/YuHayate)\
**Post date:** [April 26, 2023, 5:54pm UTC](https://forum.makecode.com/t/enums/4709/7 "2023-04-26T17:54:09Z")

</div>

the enum is like a number so  
if (direction == 1)

---

<div class="post-metadata">

**Author:** ![YuHayate](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/yuhayate/32/8275_2.png) [@YuHayate](https://forum.makecode.com/u/YuHayate)\
**Post date:** [April 26, 2023, 7:02pm UTC](https://forum.makecode.com/t/enums/4709/8 "2023-04-26T19:02:34Z")

</div>

also do this

```auto
enum Test {
         left = 1,
         right = 2,
         up = 3,
         down = 4
}

```
