【问题标题】:Syntax Error: expecting rightparen before语法错误:期待 rightparen 之前
【发布时间】:2011-08-01 19:42:09
【问题描述】:

我编写了一个单例类来跟踪我的应用程序中的一些变量。

我遇到了一个我无法弄清楚的语法错误,我确信我遗漏了一些简单的东西,但那是那些日子之一。有人发现我的代码有问题吗?

错误为 1084:语法错误:在 resultNumber 之前需要右括号。

    public static function setResult(int resultNumber, int value): void
    {
        switch(resultNumber)
        {
            case 2: { this.result2 = value; break; }
            case 3: { this.result3 = value; break; }
            case 4: { this.result4 = value; break; }
            case 5: { this.result5 = value; break; }
            case 6: { this.result6 = value; break; }
            case 7: { this.result7 = value; break; }
            case 8: { this.result8 = value; break; }
            case 9: { this.result9 = value; break; }
            case 10: { this.result10 = value; break; }
            case 11: { this.result11 = value; break; }
            case 12: { this.result12 = value; break; }
            case 13: { this.result13 = value; break; }
            case 14: { this.result14 = value; break; }
        }
    }

【问题讨论】:

    标签: flash apache-flex actionscript-3


    【解决方案1】:

    这不是 Java:

    public static function setResult(resultNumber:int, value:int): void
    {
        switch(resultNumber)
        {
            case 2: { this.result2 = value; break; }
            case 3: { this.result3 = value; break; }
            case 4: { this.result4 = value; break; }
            case 5: { this.result5 = value; break; }
            case 6: { this.result6 = value; break; }
            case 7: { this.result7 = value; break; }
            case 8: { this.result8 = value; break; }
            case 9: { this.result9 = value; break; }
            case 10: { this.result10 = value; break; }
            case 11: { this.result11 = value; break; }
            case 12: { this.result12 = value; break; }
            case 13: { this.result13 = value; break; }
            case 14: { this.result14 = value; break; }
        }
    }
    

    【讨论】:

    • 我的意思是你声明的方法参数就像在 Java 中一样。我已经用 ActionScript 的方式更正了它们。
    猜你喜欢
    • 2017-10-17
    • 2014-09-02
    • 2017-09-12
    • 2019-12-06
    • 2013-11-15
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-09-26
    相关资源
    最近更新 更多