`string` variable ending up with `null`
niden opened this issue · comments
Nikolaos Dimopoulos commented
protected final function getSpecial(int special) -> string
{
string suffix = "";
switch special {
case 1:
let suffix = "alpha";
break;
case 2:
let suffix = "beta";
break;
case 3:
let suffix = "RC";
break;
}
return suffix;
}
The above returns null
when special
is other than 1
, 2
or 3
. If a default
clause is added to the switch
it makes no difference.
Also adding
let suffix = "";
has no effect.
If the variable is changed to var suffix
then the code works (i.e. you get an empty string if special
is 4)