# Using null in case statements

**URL:** <https://forum.kirupa.com/t/using-null-in-case-statements/247941>\
**Category:** flash\
**Created:** [January 2, 2008, 3:10am UTC](https://forum.kirupa.com/t/using-null-in-case-statements/247941 "2008-01-02T03:10:51Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![anon4341189](https://avatars.discourse-cdn.com/v4/letter/a/ecae2f/32.png) [@anon4341189](https://forum.kirupa.com/u/anon4341189)\
**Post date:** [January 2, 2008, 3:10am UTC](https://forum.kirupa.com/t/using-null-in-case-statements/247941/1 "2008-01-02T03:10:51Z")

</div>

Hello all,

I currently have the following piece of code:

```auto

switch (myArray[0]){
   case null:
      trace("null case detected"); //does not trace
      break;
   case "test":
      trace("test case detected");
      break;
}

```

It does not work when myArray[0] is null;

However, the following works:

```auto

if (myArray[0] == null){
   myArray[0] == "nullhack"
}

switch (myArray[0]){
   case "nullhack":
      trace("null case detected"); //trace works
      break;
   case "test":
      trace("test case detected");
      break;
}

```

Any ideas?

Cheers 😃
