0

発生するエラーは次のとおりです。

Funct.scala:5: 'val' expected but identifier found.
[error] class Funct[In,Out](function: In => Out, description: String, implicit m: Manifest[In => Out]) {

問題のコードは次のとおりです。

import scala.reflect.Manifest;

class Funct[In,Out](function: In => Out, description: String, implicit m: Manifest[In => Out]) {

  def isType[K](implicit man: Manifest[K]) = {
    m <:< man
  }

  def Apply(input: In): Out = {
    function.Apply(input)
  }

  def toString() = {
    description + m
  }
}

私は単に問題が何であるかわかりません。

4

2 に答える 2

7

理解できるはずの問題がいくつかありますが、メッセージは確かに少しわかりにくいものです。

ここでの問題は、implicitキーワードが個々のパラメーターだけでなく、パラメーター グループ全体をマークする必要があることです。試す:

class Funct[In,Out](function: In => Out, description: String)(implicit m: Manifest[In => Out])
于 2012-08-17T01:44:37.837 に答える
3

function.Apply(input)する必要がありますが、真剣に、IntelliJまたはEclipseを使用するfunction.apply(input)だけfunction(input)で、これらのことをすぐに教えてくれます。

于 2012-08-17T01:52:39.827 に答える