Switch Case - How?

Hi
This feels like a strange post to make, given that I can do switch case in C++, SQL etc… but in Unity, I am quickly learning that Javascript syntax is a little different to the norm.

Would anyone be able to provide a simple switch case example which includes compound statements please?

This is what I expect to be able to do in Unity: -

switch (myvar)
{
  case 0: 
  {
   dostuff();
   break;
  }

  case 1:
  {
   dosomeotherstuff();
   break;
  }

  default :
  break;
}

thanks for your help.

Ryan[/code]

Take most of the braces out:

switch (myvar)
{
  case 0: 
   dostuff();
   break;

  case 1:
   dosomeotherstuff();
   break;

  default :
  break;
}

–Eric

Which is actually how you would do it in browser-based Javascript too: