Reputation: 787
I'm trying to make a function whose return type is not just a function (A=>B
), but the same function. Here is an example:
trait Command
type Config = Command => Command
def addCommand(c: Command): Config = {
addCommand _
}
The above seems to be ok, but it gives this compile error:
found : Command => Command
required: Command
Is there way to repair this thing?
Upvotes: 0
Views: 139
Reputation: 21557
How about currying?
scala> val ac: Command => Config = cm => confCom => confCom
ac: Command => (Command => Command) = <function1>
scala> val c: Config = ac(new Command {})
c: Command => Command = <function1>
Upvotes: 1