[RESOLVED] Switch case "Warning : This case is unused

I don’t understand why I get a Warning : This case is unused for the default line:

public function ReplaceCharAt(inStr:String, newChar:String, pos:Int):String
    var outStr:String;
    var len: Int;

    newChar = newChar.substr(0, 1);
    len = inStr.length;

    switch (pos) {
        case 0:outStr = newChar + inStr.substr(1);
        case len:outStr = inStr.substr(0, len - 1) + newChar;
        default:outStr = inStr.substr(0, pos) + newChar + inStr.substr(pos + 1);
    return (outStr);

switch statements work a little differently in Haxe. They support “capture variables”, which (in this case) means case len actually is sort of like default: var len = pos;

Maybe an if would be easiest?

Rewrote this one as an if statement but have others (porting from Actionscript 3) which have many more cases and then an if statement gets too unwieldy! Most of those use the AS3 const type which Haxe does not have a direct equivalent for. I used as3hx to convert my AS3 code and it converted all const to var. I now know to use “static inline var” as a substitute for “const” and that works in a switch statement.