scala> class A(implicit a: Int);
defined class A
scala> class B()(implicit a: Int);
defined class B
scala> new A()(1)
res1: A = [email protected]
scala> new B()(1)
res2: B = [email protected
當我想使用隱式方法將函數轉換爲其他東西時,我遇到了一些問題。 我正在Scala 2.8中實現一個小型DSL用於測試目的。它應該支持對實例進行各種檢查(如果你喜歡的話)。整個DSL是一個有點複雜,但下面的簡單示例說明我的問題: object PimpMyFunction {
class A(val b: Int)
def b(a: A) = a.b
class Z