2017-07-18 26 views

回答

1

缀显示的符号类型是默认在Scala 2.12.2。该更改是在this pull request中进行的。

它还在包scala.annotation添加注释showAsInfix给你的,你需要改变默认行为的情况下控制。

0

不知道这是否有助于但是你可以重写ToString方法和控制输出的第二部分,像这样:

import scala.reflect.runtime.universe.{TypeTag, typeOf} 

class A[X, Y] (implicit val tt: TypeTag[X], implicit val ty: TypeTag[Y]) { 
    override def toString() = typeOf[X] + " !: " + typeOf[Y] 
} 
new A[Int, Int]() 

输出

res15: A[Int,Int] = Int !: Int 
+0

感谢您的尝试,但我真的想能够以不同方式显示'A [Int,Int]'。我已经在我的情况下重写了toString方法。 –

相关问题