1

出来ますか?
私はこのようなことを試しました:

object foo extends Foo {
    constructorNamedArg = "qqq";
} {
    abstractMethod() => bar.baz();
}
4

2 に答える 2

4

I would not use inheritance for this. Instead I would define Foo as a concrete class:

class Foo(String constructorNamedArg, Baz abstractMethod()) {}

And now at the call site I would write:

Foo {
    constructorNamedArg = "qqq";
    abstractMethod() => bar.baz();
}

Or even:

Foo {
    constructorNamedArg = "qqq";
    function abstractMethod() { 
        return bar.baz(); 
    }
}

It's a common refactoring in Ceylon to go from abstract class with formal methods to concrete class parameterized by functions.

HTH

于 2015-12-23T11:12:31.570 に答える
2

仕様によると、それは不可能であり、位置引数リストしか存在できません。

于 2015-12-22T11:54:10.503 に答える