# Switch type of object

**URL:** <https://forum.kirupa.com/t/switch-type-of-object/290839>\
**Category:** flash\
**Created:** [June 20, 2009, 3:23pm UTC](https://forum.kirupa.com/t/switch-type-of-object/290839 "2009-06-20T15:23:37Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![superpeppe](https://avatars.discourse-cdn.com/v4/letter/s/a183cd/32.png) [@superpeppe](https://forum.kirupa.com/u/superpeppe)\
**Post date:** [June 20, 2009, 3:23pm UTC](https://forum.kirupa.com/t/switch-type-of-object/290839/1 "2009-06-20T15:23:37Z")

</div>

Hi

I want to find out which type an object has.  
Therefore I thought of the ‘switch’ statement, but how would you do that?  
The following code does not work, but you will get the point of what I want to do.

```auto
switch (object)
{
	case is String:
	trace("string");
	case is Array:
	trace("array");
	default:
	trace("something else");
}

```

A way to solve this would of course be, the use of the ‘if’ statement.

```auto

if (object is String)
{
	trace("string");
}
else if (object is Array)
{
	trace("array");
}
else
{
	trace("something else");
}

```

Thanks in advance
