0

The error it yields is:

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

and the code in question is:

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 } } 

I simply do not see what the problem is.

1
  • 1
    You left out the line from the error output with the carrot ^ showing where the parse error happened in the input line. (It's pointing at the m just after implicit.) Commented Aug 17, 2012 at 5:53

2 Answers 2

7

There are a few problems you should be able to figure out, but the message is indeed a bit confusing.

The issue here is that the implicit keyword must mark the whole parameter group and not just individual parameters. Try:

class Funct[In,Out](function: In => Out, description: String)(implicit m: Manifest[In => Out]) 
Sign up to request clarification or add additional context in comments.

Comments

3

function.Apply(input) should be function.apply(input) or just function(input), but seriously, just use IntelliJ or Eclipse and they'll tell you these things immediately.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.