Принудительный доступ к def

Учитывая

object A {
  def m(i: Int) = i
  val m = (i: Int) => i * 2
}

, получаем

scala> A.m(2)
<console>: error: ambiguous reference to overloaded definition,
both value m in object A of type => (Int) => Int
and  method m in object A of type (i: Int)Int
match argument types (Int)
       A.m(2)
         ^

Доступ к val можно сделать с помощью

scala> val fun = A.m
fun: (Int) => Int = <function1>

scala> fun(2)
res: Int = 4

или

scala> A.m.apply(2)
res: Int = 4

, но как получить доступ к def ?

10
задан Debilski 30 September 2011 в 10:43
поделиться