switch always defaults

Hi there, I have a gameObject with the following function:

function SetDigit(digit)
{
	switch(digit)
	{
	case("0"):
		print("zero");
		break;
	case("1"):
		print("one");
		break;
	case("2"):
		print("two");
		break;
	default:
		print("this should not happen");
		print(digit);
		break;
	}
}

And I use another game object to call that function, giving it a string:

function UpdateNumber(number)
{
	numberString=number.ToString();
	var backwardsCounter=numberString.Length-1;
	for(var digit in digits)
	{
		if(backwardsCounter>=0)
		{
			var myDigit=numberString[backwardsCounter];
			digit.SendMessage("SetDigit",myDigit);
			backwardsCounter--;
		}
	}
}

however, in the console I always see “this should not happen” and “1”, even though 1 is handled in my switch :confused:

Ok, I figured.

Kludge, though x.X

function SetDigit(digit)
{
	//we determine the target rotation using a lookup table
	var malz:String="digit_";
	malz=malz+digit;
	switch(malz)
	{
	case("digit_0"):
		print("zero");
		break;
	case("digit_1"):
		print("one");
		break;
	case("digit_2"):
		print("two");
		break;
	default:
		print("this should not happen");
		print(malz);
		print(typeof(malz));
		break;
	}
}