abstract-type

    3热度

    1回答

    我有以下类别: abstract class Base { type T def myMethod: T } abstract class B extends Base { type T <: String } abstract class C extends Base { type T <: Int } 现在,如果我这样写: class

    2热度

    1回答

    在下面的一段代码中,具有私有变量(名称)和该变量的访问函数的抽象类型(应该由所有派生类型定义)在模块: module baseTypeModule type, abstract :: baseType private character(len=maxLengthCompLabel) :: Name = "" ! Component name contains pr

    0热度

    1回答

    鉴于类 object A { type URLT = String } case class A(url : URLT) class ForeignStreamWriter { def writeString(str: String) {} } trait WriterA { val writer : ForeignStreamWriter

    1热度

    1回答

    我试图定义一个特质C延伸部分性状A,B,...所有特质,C和A,B,...实现一个共同的特点T。特质C应该通过调用T的实现在A,B实施T,..: trait T{ def f() } trait A extends T{ def f(){ print("A") } } trait B extends T{ def f(){ pri

    4热度

    1回答

    假设我们要定义的方式如何积累了一些数据结果: case class Data(x: Int, y: Int) 我们定义一个特点可以这样做: trait Accumulator { type R def add(acc: R, d: Data): R def zero: R } 和简单执行: trait XAccumulator extends Accumul

    8热度

    2回答

    虽然我的头碰到another question,我遇到了不同的谜语,似乎相关。这就是其中之一: trait Sys[S <: Sys[S]] { type Peer <: Sys[Peer] } trait Fenced { type Peer <: Sys[Peer] } def makeFence[S <: Sys[S]] = new Fenced { type

    0热度

    1回答

    我是walking around a problem,我发现了一个类型投影和抽象类型的新奇怪问题。假设我有一个产生交易的系统,并且有一个我想要桥接的同伴系统。下面对我来说很好: trait Txn[S <: Sys[S]] { def peer: S#Peer#Tx def newID(): S#ID def newVar[A](id: S#ID, init: A):

    2热度

    1回答

    考虑到与类型参数的性状,以及一个抽象类型的成员访问: trait Foo[A] { def schoko(f: A) : Unit } trait Bar { type A def foo: Foo[A] } trait X trait ConcreteBar extends Bar { final type A = X } 是否有任何变

    0热度

    1回答

    此问题跟在Cake pattern with overriding abstract type don't work with Upper Type Bounds中的问题。我想用<:覆盖特质中的抽象类型。前面的链接给出了解决方案,它通过在特征S中写入this: Cake with S来改变线性化的顺序。但是,我在下面的代码中添加了一个名为control的控件抽象。我想在其中调用方法t。 trait

    0热度

    3回答

    用户sumbits这是构建使用symfony的2框架与抽象类型的一种形式: <?php $form = $this->createForm(new MyAbstractType(), new MyEntity()); 我接收在动作此篇请求: public function receiveFormRequestAction(Request $request){ //How do I