2017-07-18 25 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方法。 –

相關問題