1

我写了一个定义了一堆类的 Fantom 脚本。因为我可以成功运行脚本,所以我决定将其转换为适当的 Fantom 项目,但是其中一个类无法编译,错误消息是:

Expected expression, not '|'

该类具有以下形式:

class MyClass
{
    const Func myFunc := |Foo foo, Bar bar| {
        // do stuff
    }

    MyType myVar := MyType()

    Void main() {
        // do more stuff
    }

}

我不明白为什么当这个类是 Fantom 项目的一部分时编译器会抱怨,但如果是 Fantom 脚本的一部分却不会。任何人都可以阐明一下吗?

谢谢

4

1 回答 1

1

这只是代表 Fantom 的一个糟糕的错误消息。它实际上是在抱怨这些类Foo并不Bar存在。将以下内容添加到您的项目中,所有内容都应该可以编译。

class Foo {}
class Bar {}
class MyType {}
于 2017-06-28T10:04:57.507 回答